daily pastebin goal
40%
SHARE
TWEET

Lista studenti, promovati, medie, bursieri #inC

a guest Dec 18th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma warning(disable:4996)
  2. #include<conio.h>
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5.  
  6. typedef struct {
  7.     int grupa, nota1, nota2;
  8.     char nume[100], prenume[100];
  9. }persoana;
  10.  
  11. void afis(persoana a, float m) {
  12.     printf("\n Nume: %s\n Prenume: %s\n Grupa: %d\n Medie: %.2f\n ",
  13.         a.nume, a.prenume, a.grupa, m);
  14. }
  15. void nl() {
  16.     printf("\n___________________\n");
  17. }
  18. void main() {
  19.     persoana agenda[100];
  20.     int nrstudenti = 0, promovati=0;
  21.     float mediegenerala = 0, medie[100];
  22.     printf("Nr. studenti: ");
  23.     scanf("%d", &nrstudenti);
  24.  
  25.     for (int i=0;i<nrstudenti;i++){
  26.         printf("\nNume: ");
  27.         scanf("%s", &agenda[i].nume);
  28.         printf("Prenume: ");
  29.         scanf("%s", &agenda[i].prenume);
  30.         printf("Grupa: ");
  31.         scanf("%d", &agenda[i].grupa);
  32.         printf("Nota 1: ");
  33.         scanf("%d", &agenda[i].nota1);
  34.         printf("Nota 2: ");
  35.         scanf("%d", &agenda[i].nota2);
  36.         medie[i] = ((float)agenda[i].nota1 + agenda[i].nota2) / 2;
  37.     }
  38.     for (int i = 0;i<nrstudenti;i++)
  39.         mediegenerala += medie[i];
  40.     mediegenerala /= nrstudenti;
  41.  
  42.     for (int i = 0;i < nrstudenti;i++)
  43.         if (medie[i] >= 5)
  44.             promovati++;
  45.     nl();
  46.     printf("\nDatele introduse sunt:\n");
  47.     for (int i = 0;i < nrstudenti;i++) {
  48.         printf("\nNume: %s\n Prenume: %s\n Grupa: %d\n Nota 1: %d\n Nota 2: %d\n Medie: %.2f\n ",
  49.             agenda[i].nume, agenda[i].prenume, agenda[i].grupa, agenda[i].nota1, agenda[i].nota2, medie[i]);
  50.     }
  51.     nl();
  52.     printf("\nNumar promovati: %d\nNumar nepromovati: %d\nMedie generala: %.2f\n",
  53.         promovati, (nrstudenti-promovati), mediegenerala);
  54.     nl();
  55.     printf("\nBursieri excelenti: ");
  56.     for (int i = 0;i < nrstudenti;i++)
  57.         if (medie[i] == 10)
  58.             afis(agenda[i], medie[i]);
  59.  
  60.     printf("\nBursieri performanti: ");
  61.     for (int i = 0;i < nrstudenti;i++)
  62.         if (medie[i]<10 && medie[i]>=9)
  63.             afis(agenda[i], medie[i]);
  64.  
  65.     printf("\nBursieri studenti: ");
  66.     for (int i = 0;i < nrstudenti;i++)
  67.         if (medie[i]<9 && medie[i]>=8.06)
  68.             afis(agenda[i], medie[i]);
  69.     nl();
  70.     _getch();
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top