15357
Companion Cube
- Joined
- Jan 11, 2005
- Messages
- 15,209
- Reaction score
- 23
So, I've many, many assignments for my classes, easy enough, except this.
I'm supposed to come up with 2 programs and a respective algorithm table for each one.
First one was way easy; you just have to use loops to get
*
**
***
****
and so on.
But the second one has stumped me:
Using only "for(x;x;x)" structures and "printf" thingys, I'm supposed to make a sort of 'permutation' (not sure, babelfish translation) for C.
Output should be this:
So far, the closest I could get was this:
With an output of:
So, somebody? I suck at C. I need someone useful.
Thanks in advance.
I'm supposed to come up with 2 programs and a respective algorithm table for each one.
First one was way easy; you just have to use loops to get
*
**
***
****
and so on.
But the second one has stumped me:
Using only "for(x;x;x)" structures and "printf" thingys, I'm supposed to make a sort of 'permutation' (not sure, babelfish translation) for C.
Output should be this:
Code:
123
132
213
231
312
321
So far, the closest I could get was this:
Code:
#include <stdio.h>
void main(){
int a = 0, b = 0, c = 0;
for (a = 1; a <= 3; a++){
for (b = 1; b <= 3; b++){
for (c = 1; c <= 3; c++){
printf("%d%d%d\n" , a, b, c);
}
}
}
}
With an output of:
Code:
111
112
123
211
212
213
...
and so on
So, somebody? I suck at C. I need someone useful.
Thanks in advance.