Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4. void wczytajOsobe(string & imie, string & nazwisko, int & wiek, int & n)
  5. {
  6.     cout << n++ << " osoba." << endl;
  7.     cout << "Podaj imie: ";
  8.     cin.clear();
  9.     cin.sync();
  10.     getline(cin, imie);
  11.  
  12.     cout << "Podaj nazwisko: ";
  13.     getline(cin, nazwisko);
  14.  
  15.     do
  16.     {
  17.         cout << "Podaj swoj wiek: ";
  18.         cin.clear();
  19.         cin.sync();
  20.         cin >> wiek;
  21.         if(wiek == false)
  22.             cout << "Podales wiek w zlej formie. Podaj go jeszcze raz poprawiajac bledy." << endl;
  23.     }while(cin.fail());
  24.     cout << endl;
  25. }
  26. void wypiszOsobe(string imie, string nazwisko, int wiek, int n)
  27. {
  28.     cout << n++ << " osoba." << endl;
  29.     cout << "Twoje imie to: " << imie << endl;
  30.     cout << "Twoje nazwisko to: " << nazwisko << endl;
  31.     cout << "Masz " << wiek;
  32.     if(wiek > 4)
  33.         cout << " lat." << "\n\n";
  34.     if(wiek < 5 && wiek > 1)
  35.         cout << " lata." << "\n\n";
  36.     if (wiek == 1)
  37.         cout << " rok." << "\n\n";
  38.  
  39. }
  40. int main()
  41. {
  42.     string imie[ 2 ];
  43.     string nazwisko[ 2 ];
  44.     int wiek[ 2 ];
  45.     int n = 1;
  46.     for( int i = 0; i < 2; i++ )
  47.          wczytajOsobe( imie[ i ], nazwisko[ i ], wiek[ i ], n );
  48.  
  49.     n = 1;
  50.     for( int i = 0; i < 2; i++ )
  51.          wypiszOsobe( imie[ i ], nazwisko[ i ], wiek[ i ], n );
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement