# Thread: You title it.

1. ## You title it.

What this program does is obvious. But there is a small problem: we don't need all the pairs (ex. 800x1200) and we could use less memory if we had made xy={800*600, 1024*768...}. But we want the program to print the values in a loop. Any idea to solve this problem?
Code:
```int main()
{
unsigned short x[] = {800, 1024, 1152,1600,2048};
unsigned short y[] = {600, 768, 864 ,1200, 1536};
unsigned short c[] = {2,4};
for(int cn=0; cn<2;cn++)
for(int i=0; i<5; i++)
cout<<x[i]<<"x"<<y[i]<<"x"<<c[cn]*8<<" = "<<(x[i]*y[i]*c[cn])/(1024*1024.0f)<<" MB(s)"<<endl;

return 0;
}```

2. how about a struct?
Code:
```struct foo
{
short x;
short y;
}

foo bar;
bar.x=800;
bar.y=600;```

3. how about a struct?
That wouldn't help??

What help is this.

y = x*6/8

the x's can all be divided by 32 if you really wanted to save space too

4. So I change a code a little
Code:
```int main()
{
unsigned short x[] = {800, 1024, 1152, 1600, 1920, 1920, 2048};
unsigned short y[] = {600, 768, 864, 1200, 1080, 1200, 1536};
unsigned short c[] = {2,4};
for(short cn=0; cn<2;cn++)
for(short i=0; i<7; i++)
cout<<x[i]<<"x"<<y[i]<<"x"<<c[cn]*8<<" = "<<(x[i]*y[i]*c[cn])/(1024*1024.0f)<<" MB"<<endl;

return 0;
}```

Popular pages Recent additions