Advertisement
AbraaoAllysson

questao 1 - IA

Aug 21st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. int main(int argc, char** argv)
  4. {
  5.     float x [] = {23,22.7,21.2,21.5,17,28.4,19,14.5,19,19.5};
  6.    
  7.     float soma = 0;
  8.    
  9.     for(int i = 0; i <10; i++)
  10.     {
  11.         soma += x[i];
  12.     }  
  13.    
  14.     std::cout<<"Media "<<(soma/10)<<std::endl;
  15.     float variacia = 0;
  16.     for(int i = 0; i <10; i++)
  17.     {
  18.         variacia +=  pow(x[i] - (soma/10),2) ;
  19.     }
  20.    
  21.     std::cout<<"Variancia: "<<(variacia/9)<<std::endl;
  22.    
  23.     std::cout<<"Desvio Padrao: "<<sqrtf(variacia/9)<<std::endl;
  24.     float xx [] = {14.5,17,19,19,19.5,21.2,21.5,22.7,23};
  25.     std::cout<<"Mediana: "<<((xx[5]+xx[4])/2)<<std::endl;
  26.     std::cout<<"Moda: 19"<<std::endl;
  27.    
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement