Advertisement
nontawat1996

butterfly

Aug 19th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. #define INF 2000000000
  6. #define fiMAX(x,y) (x>y?x:y)
  7. #define fiMIN(x,y) (x>y?y:x)
  8. /*
  9. IN : 4
  10. OUT :
  11. *      *
  12. **    **
  13. ***  ***
  14. ********
  15. ***  ***
  16. **    **
  17. *      *
  18. */
  19. int main()
  20. {
  21.     int N;
  22.     int i,j,k;
  23.     int L,R;
  24.     scanf("%d",&N);
  25.     L=1;
  26.     R=N*2;
  27.     for(i=1; i<=N*2-1; i++)
  28.     {
  29.         for(j=1; j<=N*2; j++)
  30.         {
  31.             if(i<=N)
  32.             {
  33.                 if(j<=L || R<=j) printf("*");
  34.                 else printf(" ");
  35.             }
  36.             else
  37.             {
  38.                 if(j>L || R>j) printf("*");
  39.                 else printf(" ");
  40.             }
  41.         }
  42.         L++;
  43.         R--;
  44.         printf("\n");
  45.     }
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement