Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. struct osoba{
  10.   string imie;
  11.   string nazwisko;
  12.   int rok;
  13.   int wiek;
  14.   float stypN;
  15.   float stypS;
  16.   };
  17.  
  18.     osoba student [2];
  19.  
  20.   void wczytaj ()
  21.   {
  22.     for (int i=0; i<2; i++)
  23.         {
  24.      cout << "Podaj kolejno dane (imie, nazwisko, rok studiow, wiek, wysokosc stypendium naukowego i socjalnego) studenta numer "<<i+1<<endl;
  25.      cin >> student[i].imie;
  26.      cin >> student[i].nazwisko;
  27.      cin >> student[i].rok;
  28.      cin >> student[i].wiek;
  29.      cin >> student[i].stypN;
  30.      cin >> student[i].stypS;
  31.         }
  32.   }
  33.  
  34.   void wypisz ()
  35.   {
  36.     for (int i=0; i<2; i++)
  37.         {
  38.       cout << "Dane ucznia numer "<<i+1<<endl;
  39.       cout << student[i].imie << " ";
  40.       cout << student[i].nazwisko << ", ";
  41.       cout << student[i].rok << " rok studiow, ";
  42.       cout << student[i].wiek << " lat, wysokosc stypendium naukowego: ";
  43.       cout << student[i].stypN << ", wysokosc stypendium socjalnego: ";
  44.       cout << student[i].stypS << endl;
  45.         }
  46.   }
  47.  
  48.   void rok ()
  49.   {
  50.       int n;
  51.       cout << "Podaj rok studiow "<<endl;
  52.       cin >> n;
  53.  
  54.       for (int i=0; i<2; i++)
  55.       {
  56.           int dlugosc = student[i].nazwisko.length();
  57.           if ((dlugosc-1=='i')&&(student[i].rok==n))
  58.           {
  59.               cout << "Dane szukanego studenta: " << endl;
  60.               cout << student[i].nazwisko;
  61.               cout << student[i].wiek << "lat";
  62.               cout << student[i].rok << "rok studiow" << endl;
  63.           }
  64.       }
  65.   }
  66.  
  67.  
  68. int main()
  69.   {
  70.  
  71.     wczytaj ();
  72.     system ("cls");
  73.     wypisz ();
  74.     rok ();
  75.  
  76.  
  77.  return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement