Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Εύα-Μαρία Καρέλα
- 321/2014074*/
- #include<stdio.h>
- #include <string.h>
- #define N 2
- #define M 2
- int main()
- {
- int i, j, B[N][M], Me, mi, Meg[N], mik[N], max, v_max[M], epilogh, k, result;
- float Mo[N], Ep[M], Ap[M], mo;
- char On[N][40], o_max[M][40], onoma[40],clean;
- /*Η παρακάτω for είναι για να γεμίσει ο πίνακας των ονομάτων και των βαθμών.*/
- for(i=0; i<N; i++)
- {
- printf("Dwste to onoma tou %d mathhth. \n", i+1);
- gets(On[i]);
- for(j=0; j<M; j++)
- {
- printf("Dwste ton bathmo tou %s gia to %d mathhma. \n", On[i], j+1);
- scanf("%d", &B[i][j]);
- while(B[i][j]<0 || B[i][j]>10)
- {
- printf("Lathos. Ksanadwste gia ton %s ton %do vathmo. \n", On[i], j+1);
- scanf("%d", &B[i][j]);
- }
- }
- fflush(stdin);
- }
- /*Η επόμενη for είναι για την πρώτη επιλογή.*/
- for(i=0; i<N; i++)
- {
- mo=0;
- for(j=0; j<M; j++)
- mo=mo+B[i][j];
- Mo[i]=mo/M;
- }
- /*Η παρακάτω for είναι για την τρίτη επιλογή.*/
- for(i=0; i<N; i++)
- {
- mi=11;
- Me=-1;
- for(j=0; j<M; j++)
- {
- if(B[i][j]<mi)
- {
- mik[i]=B[i][j];
- mi=B[i][j];
- }
- if(B[i][j]>Me)
- {
- Meg[i]=B[i][j];
- Me=B[i][j];
- }
- }
- }
- /*Η επόμενη for είναι για την επιλογή τέσσερα.*/
- for(i=0; i<M; i++)
- {
- max=-1;
- for(j=0; j<N; j++)
- if(B[i][j]>max)
- {
- v_max[i]=B[i][j];
- strcpy(o_max[i],On[i]);
- }
- }
- /*Οι επόμενες δύο for είναι για την επιλογή πέντε.*/
- for(i=0; i<N; i++)
- {
- Ep[i]=0; //Για τις επιτυχίες.
- Ap[i]=0; //Για τις αποτυχίες.
- }
- for(j=0; j<M; j++)
- for(i=0; i<N; i++)
- if(B[i][j]>=5)
- Ep[j]++;
- else
- Ap[j]++;
- /*Τώρα ξεκινάει να διαβάζει τις επιλογές μέχρι να δώσει ο
- χρήστης την 6η επιλογή για να σταματήσει το πρόγραμμα.*/
- printf("Dwste mia epilogh apo tis parakatw. \nPlhktrologiste: \n1 gia <Emfanish stoixeiwn>, \n2 gia <Emfanish stoixeiwn foithth>, \n3 gia <Emfanish mekroterou/megaluterou vathmou foithth>, \n4 gia <Emfanish tou onomatos kai ths vathmologias tou foithth me to megalutero vathmo ana mathhma>, \n5 gia <Emfanish tou posostou epituxias kai apotyxias gia kathe mathhma> \nkai telos 6 gia <Eksodo>. \n");
- scanf("%d", &epilogh);
- while(epilogh!=6)
- {
- if(epilogh==1)
- for(i=0; i<N; i++)
- printf("O/H %s exei meso oro thn vathmologia: %.1f \n", On[i], Mo[i]);
- else if(epilogh==2)
- {
- printf("Dwste onoma foithth. \n");
- scanf("%s",&onoma);
- /*Η παρακάτω for ειναι για να εντοπίσει το όνομα του φοιτητή που
- δώθηκε μέσα από τον πίνακα.*/
- for(i=0; i<N; i++)
- {
- if(strcmp(onoma,On[i])==0)
- {
- printf("O %s exei tous parakatw vathmous. \n", On[i]);
- for(j=0; j<M; j++)
- printf("Sto %d mathhma exei: %d. \n", j+1, B[i][j]);
- }
- }
- }
- else if(epilogh==3)
- for(i=0; i<N; i++)
- printf("O megaluteros vathmos tou %s einai %d kai o mikroteros tou einai %d. \n", On[i], Meg[i], mik[i]);
- else if(epilogh==4)
- for(i=0; i<N; i++)
- printf("Sto %d mathhma o megaluteros vathmos einai %d kai ton exei o %s. \n", i+1, v_max[i], o_max[i][40]);
- else if(epilogh==5)
- for(j=0; j<M; j++)
- printf("To pososto epituxias sto %d mathhma einai %d tis ekato kai apotuxias einai %d tis ekato. \n", j+1, Ep[j]*10, Ap[j]*10);
- printf("Dwste ksana epilogh. \n");
- scanf("%d", &epilogh);
- }
- printf("Termathsate me epituxia to programma.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement