i want pyramid image.i can first block. have ideas on how this? in advance.
#include <stdio.h> int main() { for(int i=0;i<=5;i++) { for(int j=0;j<=i;j++) { printf("%d",j); } printf("\n"); for(int k=5;j<=k;k--) { printf("%d",k) } for(int z=0;z<=5;z++) { printf("%d",z); } } }
#include <stdio.h> int main(void){ int n = 5; for(int = 1; <= n; ++i){//print n lines for(int j = 0; j < 2; ++j){//repeated twice //print sequence of number for(int k = 1; k <= i; ++k){ printf("%d", k); } //print space for(int k = 0; k < n - i; ++k){ printf(" ");//2 times } //print reverse sequence of number for(int k = i; k >= 1; --k){ printf("%d", k); } } printf("\n");//one line end } return 0; }
Comments
Post a Comment