Skip to content

Instantly share code, notes, and snippets.

Created Apr 30, 2015
What would you like to do?
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <cmath>
#include <vector>
using namespace std;
float desviacion( vector<int> v, int tam, int suma){
float desviacion;
int i;
float Suma_dif =0.0;
float prom = promedio(suma, tam);
for (i=0; i < tam;i++ ){
Suma_dif += ((v[i] -prom) *(v[i] - prom));
desviacion = sqrt(Suma_dif/tam);
return desviacion;
float promedio(float sum, int lines){
float promedio;
return promedio;
void readNumbers(string namefile){
ifstream file (namefile);
string line;
vector<int> number;
int line_number=0, suma =0;
if (file.is_open()){
while (getline(file, line)){
int x = atoi(line.c_str());
suma += number [line_number];
cout << "The total of the values is "<< suma << endl;
cout << "La suma total es: "<< line_number << endl;
cout << "El promedio es: "<< promedio(suma,line_number) << endl;
cout << "La desviacion estandar es " << desviacion(number, line_number, suma) << endl;
int main(){
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment