Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct student {
- string ime;
- string prezime;
- int indeks;
- double prosek;
- };
- int main() {
- int n;
- cin >> n;
- student s[n];
- for(int i = 0; i < n; i++) {
- cin >> s[i].ime >> s[i].prezime >> s[i].indeks >> s[i].prosek;
- }
- for(int i = 0; i < n; i++) {
- for(int j = i + 1; j < n; j++) {
- if(s[i].indeks > s[j].indeks) {
- student pomosna = s[i];
- s[i] = s[j];
- s[j] = pomosna;
- }
- }
- }
- for(int i = 0; i < n; i++) {
- cout << s[i].ime << " " << s[i].prezime << " " << s[i].indeks << " " << s[i].prosek << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement