Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- struct student {
- char ime[15];
- char prezime[15];
- int index;
- int poeni;
- } studenti[100];
- void golemiPocetniBukvi(int n){
- int i;
- for(i = 0; i < n; i++){
- studenti[i].ime[0] = toupper(studenti[i].ime[0]);
- studenti[i].prezime[0] = toupper(studenti[i].prezime[0]);
- }
- }
- void sort(int n){
- int i,j;
- struct student pom;
- for (i = 0 ; i < n - 1; i++){
- for (j = 0 ; j < n - i - 1; j++)
- {
- if (studenti[j].poeni < studenti[j+1].poeni)
- {
- pom = studenti[j];
- studenti[j] = studenti[j+1];
- studenti[j+1] = pom;
- }
- }
- }
- }
- int main()
- {
- int i, n, j;
- scanf("%d", &n);
- for(i = 0; i < n; i++){
- scanf("%s", &studenti[i].ime);
- scanf("%s", &studenti[i].prezime);
- scanf("%d", &studenti[i].index);
- int poeni = 0;
- studenti[i].poeni = 0;
- for(j = 0; j < 4; j++){
- scanf("%d", &poeni);
- studenti[i].poeni += poeni;
- }
- }
- golemiPocetniBukvi(n);
- sort(n);
- for(i = 0; i < n; i++){
- printf("%s %s %d %d\n", studenti[i].prezime, studenti[i].ime, studenti[i].index, studenti[i].poeni);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement