Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int x,pom=0;
- double suma=0;
- struct student
- {
- string imie;
- string nazwisko;
- int rok;
- int wiek;
- double stypN;
- double stypS;
- } dane[5];
- dane[0]={"Kamil","Nowakowski",1,20,10,350};
- dane[1]={"Dawid","Nowak",2,21,500,120};
- dane[2]={"Sebastian","Makowski",3,22,250,150};
- dane[3]={"Kamila","Pomaran",1,21,500,450};
- dane[4]={"Barbara","Nowa",2,20,100,100};
- cout<<endl<<"Dane studentow: \n==================================\n\n";
- for(int i=0;i<5;i++)
- {
- cout<<"Imie: "<<dane[i].imie<<endl;
- cout<<"Nazwisko: "<<dane[i].nazwisko<<endl;
- cout<<"Rok: "<<dane[i].rok<<endl;
- cout<<"Wiek: "<<dane[i].wiek<<endl;
- cout<<"Stypendium naukowe: "<<dane[i].stypN<<endl;
- cout<<"Stypendium socjalne: "<<dane[i].stypS<<endl;
- cout<<"\n==================================\n\n";
- }
- cout<<"Podaj rok studiow: ";
- cin>>x;
- cout<<"\nStudenci, ktorych nazwisko konczy sie litera \"i\" oraz sa na "<<x<<" roku studiow:"<<endl;
- cout<<"\n==================================\n\n";
- for(int i=0;i<5;i++)
- {
- int dl=dane[i].nazwisko.size();
- if(dane[i].rok==x && dane[i].nazwisko.at(dl-1)=='i')
- {
- cout<<"Imie: "<<dane[i].imie<<endl;
- cout<<"Nazwisko: "<<dane[i].nazwisko<<endl;
- cout<<"Rok: "<<dane[i].rok<<endl;
- cout<<"Wiek: "<<dane[i].wiek<<endl;
- cout<<"Stypendium naukowe: "<<dane[i].stypN<<endl;
- cout<<"Stypendium socjalne: "<<dane[i].stypS<<endl;
- cout<<"\n==================================\n\n";
- pom++;
- }
- }
- if(pom==0)
- cout<<"Nie ma takich studentow!\n\n==================================\n\n";
- cout<<"Suma stypendiow socjalnych studentow pierwszego roku wynosi: ";
- for(int i=0;i<5;i++)
- if(dane[i].rok==1)
- suma+=dane[i].stypS;
- cout<<suma;
- cout<<"\n\n==================================\n\n";
- cout<<"Studenci, ktorzy otrzymuja najwyzsze stypendium naukowe: ";
- double maximum=dane[0].stypN;
- for(int i=1;i<5;i++)
- if(dane[i].stypN>maximum)
- maximum=dane[i].stypN;
- for(int i=0;i<5;i++)
- if(dane[i].stypN==maximum)
- cout<<dane[i].nazwisko<<", ";
- cout<<"\n\n==================================\n\n";
- cout<<"Liczba studentow, ktorzy otrzymuja najnizsze stypendium socjalne: ";
- double minimum=dane[0].stypS, ileSocjalnych=0;
- for(int i=1;i<5;i++)
- if(dane[i].stypS<minimum)
- minimum=dane[i].stypS;
- for(int i=0;i<5;i++)
- if(dane[i].stypS==minimum)
- ileSocjalnych++;
- cout<<ileSocjalnych;
- cout<<"\n\n==================================\n\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement