Pyramid Problem No. 91

 Q.91 Print half-square number triangle as:

543212345
 4321234
  32123
   212
    1

Solving in C:

#include <stdio.h>
    int main(){
        int row,col;
        for(row=1; row<=5; row++){
            for(col=5; col>=1; col--){
                if(5-row+1<col)  printf(" ");
                else printf("%d",col);
            }
            for(col=2; col<=5-row+1; col++) printf("%d",col);
            printf("\n");
        }
        return 0;
    }

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85