Advertisement
Cy_Dreamer

Untitled

Nov 27th, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. /*Εύα-Μαρία Καρέλα
  2. 321/2014074*/
  3.  
  4. #include<stdio.h>
  5. #include <string.h>
  6. #define N 2
  7. #define M 2
  8. int main()
  9. {
  10. int i, j, B[N][M], Me, mi, Meg[N], mik[N], max, v_max[M], epilogh, k, result;
  11. float Mo[N], Ep[M], Ap[M], mo;
  12. char On[N][40], o_max[M][40], onoma[40],clean;
  13.  
  14. /*Η παρακάτω for είναι για να γεμίσει ο πίνακας των ονομάτων και των βαθμών.*/
  15.  
  16. for(i=0; i<N; i++)
  17. {
  18. printf("Dwste to onoma tou %d mathhth. \n", i+1);
  19. gets(On[i]);
  20. for(j=0; j<M; j++)
  21. {
  22. printf("Dwste ton bathmo tou %s gia to %d mathhma. \n", On[i], j+1);
  23. scanf("%d", &B[i][j]);
  24. while(B[i][j]<0 || B[i][j]>10)
  25. {
  26. printf("Lathos. Ksanadwste gia ton %s ton %do vathmo. \n", On[i], j+1);
  27.  
  28. scanf("%d", &B[i][j]);
  29. }
  30. }
  31. fflush(stdin);
  32. }
  33.  
  34. /*Η επόμενη for είναι για την πρώτη επιλογή.*/
  35.  
  36. for(i=0; i<N; i++)
  37. {
  38. mo=0;
  39. for(j=0; j<M; j++)
  40. mo=mo+B[i][j];
  41. Mo[i]=mo/M;
  42. }
  43.  
  44. /*Η παρακάτω for είναι για την τρίτη επιλογή.*/
  45.  
  46. for(i=0; i<N; i++)
  47. {
  48. mi=11;
  49. Me=-1;
  50.  
  51. for(j=0; j<M; j++)
  52. {
  53. if(B[i][j]<mi)
  54. {
  55. mik[i]=B[i][j];
  56. mi=B[i][j];
  57. }
  58.  
  59. if(B[i][j]>Me)
  60. {
  61. Meg[i]=B[i][j];
  62. Me=B[i][j];
  63. }
  64. }
  65. }
  66.  
  67. /*Η επόμενη for είναι για την επιλογή τέσσερα.*/
  68.  
  69. for(i=0; i<M; i++)
  70. {
  71. max=-1;
  72. for(j=0; j<N; j++)
  73. if(B[i][j]>max)
  74. {
  75. v_max[i]=B[i][j];
  76. strcpy(o_max[i],On[i]);
  77. }
  78. }
  79.  
  80. /*Οι επόμενες δύο for είναι για την επιλογή πέντε.*/
  81.  
  82. for(i=0; i<N; i++)
  83. {
  84. Ep[i]=0; //Για τις επιτυχίες.
  85. Ap[i]=0; //Για τις αποτυχίες.
  86. }
  87. for(j=0; j<M; j++)
  88. for(i=0; i<N; i++)
  89. if(B[i][j]>=5)
  90. Ep[j]++;
  91. else
  92. Ap[j]++;
  93. /*Τώρα ξεκινάει να διαβάζει τις επιλογές μέχρι να δώσει ο
  94. χρήστης την 6η επιλογή για να σταματήσει το πρόγραμμα.*/
  95.  
  96.  
  97. 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");
  98. scanf("%d", &epilogh);
  99.  
  100. while(epilogh!=6)
  101. {
  102. if(epilogh==1)
  103. for(i=0; i<N; i++)
  104. printf("O/H %s exei meso oro thn vathmologia: %.1f \n", On[i], Mo[i]);
  105. else if(epilogh==2)
  106. {
  107. printf("Dwste onoma foithth. \n");
  108. scanf("%s",&onoma);
  109.  
  110. /*Η παρακάτω for ειναι για να εντοπίσει το όνομα του φοιτητή που
  111. δώθηκε μέσα από τον πίνακα.*/
  112.  
  113. for(i=0; i<N; i++)
  114. {
  115. if(strcmp(onoma,On[i])==0)
  116. {
  117. printf("O %s exei tous parakatw vathmous. \n", On[i]);
  118. for(j=0; j<M; j++)
  119. printf("Sto %d mathhma exei: %d. \n", j+1, B[i][j]);
  120. }
  121. }
  122. }
  123. else if(epilogh==3)
  124. for(i=0; i<N; i++)
  125. printf("O megaluteros vathmos tou %s einai %d kai o mikroteros tou einai %d. \n", On[i], Meg[i], mik[i]);
  126. else if(epilogh==4)
  127. for(i=0; i<N; i++)
  128. printf("Sto %d mathhma o megaluteros vathmos einai %d kai ton exei o %s. \n", i+1, v_max[i], o_max[i][40]);
  129. else if(epilogh==5)
  130. for(j=0; j<M; j++)
  131. 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);
  132.  
  133. printf("Dwste ksana epilogh. \n");
  134. scanf("%d", &epilogh);
  135. }
  136.  
  137. printf("Termathsate me epituxia to programma.");
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement