Advertisement
TawratNibir

Untitled

Nov 18th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. /*
  2.    *  
  3.   ***
  4.  *****
  5. *******
  6. where row = 4
  7.  
  8.  
  9. */
  10.  
  11.  
  12. #include<stdio.h>
  13.  
  14. int main() {
  15.     int n, m;
  16.     scanf("%d", &n);
  17.     int row = n;
  18.     int collumn = (2 * n) - 1;
  19.     int low = (collumn + 1)/2;
  20.     int high = low;
  21.     for(int i=1;i<=row;i++) {
  22.         for(int j=1;j<=collumn;j++) {
  23.             if(j>=low&&j<=high) {
  24.                 printf("*");
  25.             }
  26.             else {
  27.                 printf(" ");
  28.             }
  29.         }
  30.         printf("\n");
  31.         low--;
  32.         high++;
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement