seergiomv

Ejercicio 20.4

Jan 3rd, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define N 15
  4.  
  5. struct notas{
  6.     char nombre[50];
  7.     float nota;
  8. };
  9. struct notas n[N];
  10. int main(){
  11.     float max = 0, min = 10;
  12.     char nombre1[50];
  13.     char nombre2[50];
  14.     for (int i = 0; i < N; i++){
  15.         printf("Nombre alumno: ");
  16.         gets(n[i].nombre);
  17.         printf("Nota: ");
  18.         scanf("%f",&n[i].nota);
  19.         while(getchar()!= '\n');
  20.     }
  21.     for(int i = 0; i < N; i++){
  22.         if (n[i].nota < min){
  23.             min = n[i].nota;
  24.             strcpy(nombre1,n[i].nombre);
  25.         }
  26.         if (n[i].nota > max){
  27.             max = n[i].nota;
  28.             strcpy(nombre2,n[i].nombre);
  29.         }
  30.     }
  31.     printf("\nEl alumno %s tiene la nota más alta que es %f\n",nombre2,max);
  32.     printf("El alumno %s tiene la nota más baja que es %f\n",nombre1,min);
  33.     for (int i = 0; i < N ; i++){
  34.         printf("Alumno:%s\tNota:%f\n",n[i].nombre,n[i].nota);
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment