Advertisement
NS2A2

Viên Kim Cương

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