Meseriasul

Problema 14

Dec 7th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. //Se citesc notele a n elevi la extemporal. Sa se afiseze care este nota maxima la test si de catre cati elevi a fost obtinuta.
  2.  
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. void main(){
  7.     int i,n,max = 0, nota = 0, last_max = 0, contor = 1;
  8.     printf("Numarul de elevi: "); scanf("%d", &n);
  9.     for(i = 1; i <= n; i++){
  10.         printf("Nota %d = ", i); scanf("%d", &nota);
  11.  
  12.         if(nota >= last_max){
  13.             last_max = nota;
  14.             if(last_max > max){
  15.                 last_max = max;
  16.                 max = nota;
  17.             }else if(last_max == max){
  18.                 contor++;
  19.             }
  20.         }
  21.     }
  22.     printf("Nota maxima este %d, obtinuta de %d elevi.", max, contor);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment