Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- void wczytajOsobe(string & imie, string & nazwisko, int & wiek, int & n)
- {
- cout << n++ << " osoba." << endl;
- cout << "Podaj imie: ";
- cin.clear();
- cin.sync();
- getline(cin, imie);
- cout << "Podaj nazwisko: ";
- getline(cin, nazwisko);
- do
- {
- cout << "Podaj swoj wiek: ";
- cin.clear();
- cin.sync();
- cin >> wiek;
- if(wiek == false)
- cout << "Podales wiek w zlej formie. Podaj go jeszcze raz poprawiajac bledy." << endl;
- }while(cin.fail());
- cout << endl;
- }
- void wypiszOsobe(string imie, string nazwisko, int wiek, int n)
- {
- cout << n++ << " osoba." << endl;
- cout << "Twoje imie to: " << imie << endl;
- cout << "Twoje nazwisko to: " << nazwisko << endl;
- cout << "Masz " << wiek;
- if(wiek > 4)
- cout << " lat." << "\n\n";
- if(wiek < 5 && wiek > 1)
- cout << " lata." << "\n\n";
- if (wiek == 1)
- cout << " rok." << "\n\n";
- }
- int main()
- {
- string imie[ 2 ];
- string nazwisko[ 2 ];
- int wiek[ 2 ];
- int n = 1;
- for( int i = 0; i < 2; i++ )
- wczytajOsobe( imie[ i ], nazwisko[ i ], wiek[ i ], n );
- n = 1;
- for( int i = 0; i < 2; i++ )
- wypiszOsobe( imie[ i ], nazwisko[ i ], wiek[ i ], n );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement