please can any one solve this in C ******* *** *** ** ** * *
F frogonfloor Broken In Nov 19, 2007 #1 please can any one solve this in C ******* *** *** ** ** * * Click to expand... Last edited: Nov 19, 2007
QwertyManiac Commander in Chief Nov 20, 2007 #2 Pretty simple construct really, is this a challenge or could you not do it? Code: #include<stdio.h> int main() { int i, j; for(i=4;i>0;i--) { for(j=2*i;j>0;j--) { printf("*"); if(j==i+1) printf(" "); } printf("\n"); } } Outputs as: Code: **** **** *** *** ** ** * *
Pretty simple construct really, is this a challenge or could you not do it? Code: #include<stdio.h> int main() { int i, j; for(i=4;i>0;i--) { for(j=2*i;j>0;j--) { printf("*"); if(j==i+1) printf(" "); } printf("\n"); } } Outputs as: Code: **** **** *** *** ** ** * *
OP F frogonfloor Broken In Nov 20, 2007 #3 thank you for helping me i am new in C but my question was this ******* *** *** ** ** * * not this **** **** *** *** ** ** * *
thank you for helping me i am new in C but my question was this ******* *** *** ** ** * * not this **** **** *** *** ** ** * *
QwertyManiac Commander in Chief Nov 20, 2007 #4 Huh? Doesn't look like a definite pattern to me, why would you wanna build it? Are there any rules specified? Anyway, here's my shot again: Code: #include<stdio.h> int main() { int i, j, a[4]={3, 3, 2, 1}; for(i=0;i<4;i++) { for(j=(2*a[i]);j>0;j--) { printf("*"); if((i==0)&&(j==a[i]+1)) { printf("*"); continue; } if(j==a[i]+1) { printf(" "); continue; } } printf("\n"); } } Outputs as: Code: ******* *** *** ** ** * * Its stupid to do this when there are no rules at all cause you can directly print the pattern!
Huh? Doesn't look like a definite pattern to me, why would you wanna build it? Are there any rules specified? Anyway, here's my shot again: Code: #include<stdio.h> int main() { int i, j, a[4]={3, 3, 2, 1}; for(i=0;i<4;i++) { for(j=(2*a[i]);j>0;j--) { printf("*"); if((i==0)&&(j==a[i]+1)) { printf("*"); continue; } if(j==a[i]+1) { printf(" "); continue; } } printf("\n"); } } Outputs as: Code: ******* *** *** ** ** * * Its stupid to do this when there are no rules at all cause you can directly print the pattern!