Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void troj_A() {
- int x, y, h;
- cout << "Podaj h: \n"; cin >> h;
- cout << "Podaj x: \n"; cin >> x;
- cout << "Podaj y: \n"; cin >> y;
- for(int i = 0; i < y - 1; i++) {
- cout << "\n";
- }
- for(int i = 1; i <= h; i++) {
- for (int j = 0; j < x - 1; j++) {
- cout << " ";
- }
- for(int j = 0; j < 2 * h - ((2 * i) - 1); j++) {
- cout << "*";
- }
- cout << "\n";
- }
- }
- void troj_B() {
- int x, y, h;
- cout << "Podaj h: \n"; cin >> h;
- cout << "Podaj x: \n"; cin >> x;
- cout << "Podaj y: \n"; cin >> y;
- int i = 1;
- while (i < y - ( h / 2 ) - 1) {
- cout << "\n";
- i++;
- }
- i = 0;
- while (i <= (h - 1) / 2) {
- int j = 0;
- while (j < x - (( h + 1 ) / 2)) {
- cout << " ";
- j++;
- }
- j = 0;
- while (j < i) {
- cout << "*";
- j++;
- }
- cout << "\n";
- i++;
- }
- i = 0;
- while (i < x - (h + 1) / 2) {
- cout << " ";
- i++;
- }
- i = 0;
- while (i < ( h + 1 ) / 2) {
- cout << "*";
- i++;
- }
- cout << "\n";
- i = 0;
- while (i <= (h - 1) / 2) {
- int j = 0;
- while (j < x - (( h + 1) / 2)) {
- cout << " ";
- j++;
- }
- j = ( ( h - 1 ) / 2 ) - 1 ;
- while (j >= i) {
- cout << "*";
- j--;
- }
- cout << "\n";
- i++;
- }
- }
- void troj_C() {
- }
- int main() {
- char w;
- do {
- cout << "Rysuj trojkat A - A";
- cout << "\nRysuj trojkat B - B";
- cout << "\nRysuj trojkat C - C";
- cout << "\nKoniec - K\n";
- cin >> w;
- switch (w) {
- case 'A' : troj_A(); break;
- case 'B' : troj_B(); break;
- case 'C' : troj_C(); break;
- }
- cout << "\n";
- } while (w!='K'&&w!='k');
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement