0
How to improve this table (C)
#include <stdio.h> int main () { // Please help me to improve this // I know this sucks :) int x=0, y=1; int z; while (x <= 10) { z=x*y; printf ("%d * %d = %d\n",x,y,z); x++; if (x==11){ y++; x=0; if (y==11) break; } } return 0; }
1 ответ
+ 2
It does't suck... It works and It's easy to understand... It's a matter of taste...
#include <stdio.h>
int main () {
int x = 0, y = 1;
while(y <= 10) {
x = 0;
printf ("\n\n");
while (x <= 10) {
printf ("%2d * %2d = %3d\n", x, y, x * y);
x++;
}
y++;
}
return 0;
}
You can replace while with for... etc. etc.