Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string>
- #include <iostream>
- using namespace std;
- class Student {
- private:
- string ime;
- string prezime;
- string smjer;
- double prosjek;
- public:
- bool operator<(const Student& stud) {
- Student student;
- if (this->prosjek < stud.prosjek)
- {
- return true;
- }
- else
- return false;
- }
- bool operator>(const Student& stud) {
- Student student;
- if (this->prosjek > stud.prosjek)
- {
- return true;
- }
- else
- return false;
- }
- void Unos()
- {
- cout << "Unesite ime studenta: ";
- cin >> ime;
- cout << "Unesite prezime studenta: ";
- cin >> prezime;
- cout << "Unesite smjer studenta: ";
- cin >> smjer;
- cout << "Unesite prosjek ocjena studenta: ";
- cin >> prosjek;
- }
- void Ispis()
- {
- cout << ime << " " << prezime << " " << smjer << " " << prosjek << endl;
- }
- string DohvatiSmjer() {
- return smjer;
- }
- double DohvatiProsjek() {
- return prosjek;
- }
- };
- int main()
- {
- Student studenti[3];
- for (int i = 0; i < 3; i++)
- {
- cout << "[" << i+1 << "].";
- studenti[i].Unos();
- }
- for (int i = 0; i < 2; i++)
- {
- for (int j = 0; j < 3-i-1; j++)
- {
- if (studenti[j] > studenti[j+1])
- {
- Student temp = studenti[j];
- studenti[j] = studenti[j + 1];
- studenti[j + 1] = temp;
- }
- }
- }
- for (int i = 0; i < 3; i++)
- {
- studenti[i].Ispis();
- }
- for (int i = 0; i < 3; i++)
- {
- if (studenti[i].DohvatiProsjek() > 3 && studenti[i].DohvatiSmjer() == "Racunarstvo")
- {
- studenti[i].Ispis();
- }
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement