Advertisement
Guest User

Triangle printing

a guest
Aug 23rd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5.     int n, row, col;
  6.  
  7.     n = 0;
  8.  
  9.     printf("N: ");
  10.     scanf(" %d", &n);
  11.     //printf("\n");
  12.  
  13.     for(row = 1; row <= n; row++){
  14.  
  15.         for(col = n; col > row; col--){
  16.             printf(" ");
  17.         }
  18.  
  19.         for(col = 1; col <= 2 * row - 1; col++){
  20.             printf("o");
  21.         }
  22.  
  23.         printf("\n");
  24.        
  25.     }
  26.  
  27.     row = 0;
  28.     col = 0;
  29.  
  30.     for(row = 1; row < n; row++){
  31.  
  32.         for(col = 1; col <= row; col++){
  33.  
  34.             printf(" ");
  35.  
  36.         }
  37.  
  38.         for(col = 1; col <= 2 * (n - row) - 1; col++){
  39.             printf("o");
  40.         }
  41.  
  42.         printf("\n");
  43.  
  44.     }
  45.  
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement