I\'m trying to print this big X pattern:
x x
x x
x x
x x
x
x x
x x
x x
x x
I can\'t figure out
#include
int main(){
int n = 5 - 1;
char ch[] = "x";
int i = 0, dx = 1;
do{
printf("%*s%*.*s\n", i+1, ch, 2*(n-i),2*(n-i), ch);
if((i += dx)==n)
dx = -dx;
}while(i>=0);
return 0;
}
for(;;){
printf("%*s%*.*s\n", i+1, ch, 2*(n-i),2*(n-i), ch);
if((i += dx)==n)
dx = -dx;
else if(i < 0)
break;
}
int n = 5 - 1;
char ch[] = "x";
int i = 0;
for(; i < n ; ++i){
printf("%*s%*.*s\n", i+1, ch, 2*(n-i),2*(n-i), ch);
}
for(; i >=0 ; --i){
printf("%*s%*.*s\n", i+1, ch, 2*(n-i),2*(n-i), ch);
}