Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int MAXNAP = 20;
- const int MAXSTUD = 4;
- struct Wyniki
- {
- char imie[MAXNAP];
- char nazwisko[MAXNAP];
- int numerIndeksu;
- int liczba_punktow;
- };
- void najlepszy(Wyniki* tab)
- {
- int best = tab[0].liczba_punktow;
- int j = 0;
- for(int i = 1; i < MAXSTUD; ++i)
- if(tab[i].liczba_punktow > best)
- {
- best = tab[i].liczba_punktow;
- j = i;
- }
- cout << "Najlepszy wynik osiagnal student nr " << tab[j].numerIndeksu << ":\n";
- cout << tab[j].imie << " " << tab[j].nazwisko << ": " << tab[j].liczba_punktow << "pkt\n\n";
- }
- /*Wyniki* najlepszy(Wyniki* tab)
- {
- int best = tab[0].liczba_punktow;
- int j = 0;
- for(int i = 1; i < MAXSTUD; ++i)
- if(tab[i].liczba_punktow > best)
- {
- best = tab[i].liczba_punktow;
- j = i;
- }
- return &tab[j];
- }
- void pokazWynik(Wyniki* tab)
- {
- cout << "student nr " << tab[i].numerIndeksu << ":\n";
- cout << tab[i].imie << " " << tab[i].nazwisko << ": " << tab[i].liczba_punktow << "pkt\n\n";
- }*/
- void wczytaj(Wyniki* tab)
- {
- cout << "Podaj dane studentow.\n";
- for(int ile = 0; ile < MAXSTUD; ++ile)
- {
- cout << "\timie: ";
- cin >> tab[ile].imie;
- cout << "\tnazwisko: ";
- cin >> tab[ile].nazwisko;
- cout << "\tnumer indeksu: ";
- cin >> tab[ile].numerIndeksu;
- cout << "\tliczba punktow: ";
- cin >> tab[ile].liczba_punktow;
- cout << endl;
- }
- }
- void pokazWyniki(Wyniki* tab)
- {
- for(int i = 0; i < MAXSTUD; ++i)
- {
- cout << "student nr " << tab[i].numerIndeksu << ":\n";
- cout << tab[i].imie << " " << tab[i].nazwisko << ": " << tab[i].liczba_punktow << "pkt\n\n";
- }
- }
- int main()
- {
- Wyniki wyniki[MAXSTUD];
- wczytaj(wyniki);
- pokazWyniki(wyniki);
- najlepszy(wyniki);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement