Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- #include <iostream.h>
- void main()
- {
- int a, b, c, d;
- for (int a = 1; a <= 5; a++)
- {
- for (int b = 1; b <= a; b++)
- {
- cout << "*";
- }
- cout << endl;
- }
- cout << endl;
- for (int a = 5; a >= 1; a--) // kalau tadi dari 1 sampai n, sekarang dari n sampai 1 (hitung mundur)
- {
- for (int b = 1; b <= a; b++)
- {
- cout << "*";
- }
- cout << endl;
- }
- cout << endl;
- for (int a = 1; a <= 5; a++)
- {
- int c = 5 - a;
- for (int d = 1; d <= c; d++)
- {
- cout << " ";
- }
- for (int b = 1; b <= a; b++)
- {
- cout << "*";
- }
- cout << endl;
- }
- cout << endl;
- for (int a = 1; a <= 5; a++)
- {
- int b = a - 1;
- for (int c = 1; c <= b; c++)
- {
- cout << " ";
- }
- b = 5 - a + 1;
- for (int c = 1; c <= b; c++)
- {
- cout << "*";
- }
- cout << endl;
- }
- for (int a = 1; a <= 5; a++)
- {
- int b = a - 1;
- for (int c = 1; c <= b; c++)
- {
- cout << " ";
- }
- b = (2 * 5) - (2 * a - 1);
- for (int c = 1; c <= b; c++)
- {
- cout << "*";
- }
- cout << endl;
- }
- cout << endl;
- for(int a=1;a<=5;a++)
- {
- for(int b=5;b>=a;b--)
- {
- cout<<" ";
- }
- for(int c=1;c<=a+(a-1);c++)
- {
- cout<<"*";
- }
- cout << endl;
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement