Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main()
  10.  
  11. {
  12.  
  13.     int x,pom=0;
  14.  
  15.     double suma=0;
  16.  
  17.     struct student
  18.  
  19.     {
  20.  
  21.         string imie;
  22.  
  23.         string nazwisko;
  24.  
  25.         int rok;
  26.  
  27.         int wiek;
  28.  
  29.         double stypN;
  30.  
  31.         double stypS;
  32.  
  33.     } dane[5];
  34.  
  35.  
  36.  
  37.     dane[0]={"Kamil","Nowakowski",1,20,10,350};
  38.  
  39.     dane[1]={"Dawid","Nowak",2,21,500,120};
  40.  
  41.     dane[2]={"Sebastian","Makowski",3,22,250,150};
  42.  
  43.     dane[3]={"Kamila","Pomaran",1,21,500,450};
  44.  
  45.     dane[4]={"Barbara","Nowa",2,20,100,100};
  46.  
  47.     cout<<endl<<"Dane studentow: \n==================================\n\n";
  48.  
  49.     for(int i=0;i<5;i++)
  50.  
  51.     {
  52.  
  53.         cout<<"Imie: "<<dane[i].imie<<endl;
  54.  
  55.         cout<<"Nazwisko: "<<dane[i].nazwisko<<endl;
  56.  
  57.         cout<<"Rok: "<<dane[i].rok<<endl;
  58.  
  59.         cout<<"Wiek: "<<dane[i].wiek<<endl;
  60.  
  61.         cout<<"Stypendium naukowe: "<<dane[i].stypN<<endl;
  62.  
  63.         cout<<"Stypendium socjalne: "<<dane[i].stypS<<endl;
  64.  
  65.         cout<<"\n==================================\n\n";
  66.  
  67.     }
  68.  
  69.     cout<<"Podaj rok studiow: ";
  70.  
  71.     cin>>x;
  72.  
  73.     cout<<"\nStudenci, ktorych nazwisko konczy sie litera \"i\" oraz sa na "<<x<<" roku studiow:"<<endl;
  74.  
  75.     cout<<"\n==================================\n\n";
  76.  
  77.     for(int i=0;i<5;i++)
  78.  
  79.     {
  80.  
  81.         int dl=dane[i].nazwisko.size();
  82.  
  83.         if(dane[i].rok==x && dane[i].nazwisko.at(dl-1)=='i')
  84.  
  85.         {
  86.  
  87.             cout<<"Imie: "<<dane[i].imie<<endl;
  88.  
  89.             cout<<"Nazwisko: "<<dane[i].nazwisko<<endl;
  90.  
  91.             cout<<"Rok: "<<dane[i].rok<<endl;
  92.  
  93.             cout<<"Wiek: "<<dane[i].wiek<<endl;
  94.  
  95.             cout<<"Stypendium naukowe: "<<dane[i].stypN<<endl;
  96.  
  97.             cout<<"Stypendium socjalne: "<<dane[i].stypS<<endl;
  98.  
  99.             cout<<"\n==================================\n\n";
  100.  
  101.             pom++;
  102.  
  103.         }
  104.  
  105.     }
  106.  
  107.     if(pom==0)
  108.  
  109.         cout<<"Nie ma takich studentow!\n\n==================================\n\n";
  110.  
  111.  
  112.  
  113.     cout<<"Suma stypendiow socjalnych studentow pierwszego roku wynosi: ";
  114.  
  115.     for(int i=0;i<5;i++)
  116.  
  117.         if(dane[i].rok==1)
  118.  
  119.             suma+=dane[i].stypS;
  120.  
  121.     cout<<suma;
  122.  
  123.     cout<<"\n\n==================================\n\n";
  124.  
  125.  
  126.  
  127.     cout<<"Studenci, ktorzy otrzymuja najwyzsze stypendium naukowe: ";
  128.  
  129.     double maximum=dane[0].stypN;
  130.  
  131.     for(int i=1;i<5;i++)
  132.  
  133.         if(dane[i].stypN>maximum)
  134.  
  135.             maximum=dane[i].stypN;
  136.  
  137.     for(int i=0;i<5;i++)
  138.  
  139.         if(dane[i].stypN==maximum)
  140.  
  141.             cout<<dane[i].nazwisko<<", ";
  142.  
  143.     cout<<"\n\n==================================\n\n";
  144.  
  145.  
  146.  
  147.     cout<<"Liczba studentow, ktorzy otrzymuja najnizsze stypendium socjalne: ";
  148.  
  149.     double minimum=dane[0].stypS, ileSocjalnych=0;
  150.  
  151.     for(int i=1;i<5;i++)
  152.  
  153.         if(dane[i].stypS<minimum)
  154.  
  155.             minimum=dane[i].stypS;
  156.  
  157.     for(int i=0;i<5;i++)
  158.  
  159.         if(dane[i].stypS==minimum)
  160.  
  161.             ileSocjalnych++;
  162.  
  163.     cout<<ileSocjalnych;
  164.  
  165.     cout<<"\n\n==================================\n\n";
  166.  
  167.  
  168.  
  169.  
  170.  
  171.     return 0;
  172.  
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement