Advertisement
Guest User

NNN

a guest
Jul 1st, 2013
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include    <stdio.h> /*Determinar a média de n numeros; o desvio padrão; e quantas notas são maior que a media*/
  2. #include    <math.h>
  3. main()
  4. {
  5.     int cont=0,z[10000], i, somatodos = 0;
  6.     int n, notasmaior = 0;
  7.     float media = 0, desviopadrao = 0;
  8.     float var=0;
  9.     /* LEITURA */
  10.  
  11.     while(n!=-1)
  12.     {
  13.     scanf("%d",&n);
  14.     somatodos+=n;
  15.     cont++;
  16.     for(i=0;i<10000;i++)
  17.     {
  18.         z[i]=n;
  19.     }
  20.     }
  21.     float array_a[10000];
  22.     /*Media*/
  23.     media+=somatodos/cont;
  24.     /* Quantidade de notas maiores que a media*/
  25.     for(i=0; i<cont; i++)
  26.     {
  27.         if(z[i]>media)
  28.         {
  29.             notasmaior++;
  30.         }
  31.     }
  32.     for(i=0; i<10000; i++)
  33.     {
  34.  
  35.         array_a[i]=pow(n[i]-media,2);
  36.         var+=array_a[cont];
  37.     }
  38.     desviopadrao=sqrt(var)/cont-1;
  39.     printf("%.2f\n",media);
  40.     printf("%.2f\n",desviopadrao);
  41.     printf("%d\n",notasmaior);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement