Advertisement
bl4ck4ng3l

Untitled

Jun 9th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <iostream.h>
  4.  
  5. void main()
  6.  
  7. {
  8. int a, b, c, d;
  9.     for (int a = 1; a <= 5; a++)
  10.     {
  11.         for (int b = 1; b <= a; b++)
  12.         {
  13.             cout << "*";
  14.         }
  15.         cout << endl;
  16.  
  17.     }
  18.     cout << endl;
  19.  
  20.     for (int a = 5; a >= 1; a--) // kalau tadi dari 1 sampai n, sekarang dari n sampai 1 (hitung mundur)
  21.     {
  22.         for (int b = 1; b <= a; b++)
  23.         {
  24.             cout << "*";
  25.         }
  26.         cout << endl;
  27.     }
  28.     cout << endl;
  29.  
  30.    for (int a = 1; a <= 5; a++)
  31.     {
  32.         int c = 5 - a;
  33.         for (int d = 1; d <= c; d++)
  34.         {
  35.             cout << " ";
  36.         }
  37.  
  38.         for (int b = 1; b <= a; b++)
  39.         {
  40.             cout << "*";
  41.         }
  42.         cout << endl;
  43.     }
  44.     cout << endl;
  45.  
  46.     for (int a = 1; a <= 5; a++)
  47.     {
  48.         int b = a - 1;
  49.         for (int c = 1; c <= b; c++)
  50.         {
  51.             cout << " ";
  52.         }
  53.  
  54.         b = 5 - a + 1;
  55.         for (int c = 1; c <= b; c++)
  56.         {
  57.             cout << "*";
  58.         }
  59.         cout << endl;
  60.         }
  61.  
  62.  
  63.     for (int a = 1; a <= 5; a++)
  64.     {
  65.         int b = a - 1;
  66.         for (int c = 1; c <= b; c++)
  67.         {
  68.             cout << " ";
  69.         }
  70.  
  71.         b = (2 * 5) - (2 * a - 1);
  72.         for (int c = 1; c <= b; c++)
  73.         {
  74.             cout << "*";
  75.         }
  76.         cout << endl;
  77.     }
  78.     cout << endl;
  79.  
  80.  
  81.    for(int a=1;a<=5;a++)
  82. {
  83.     for(int b=5;b>=a;b--)
  84.    {
  85.        cout<<" ";
  86.    }
  87.    for(int c=1;c<=a+(a-1);c++)
  88.    {
  89.        cout<<"*";
  90.    }
  91.    cout << endl;
  92. }
  93.     getch();
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement