Skip to content

Instantly share code, notes, and snippets.

@chukitow
Created December 6, 2013 21:52
Show Gist options
  • Save chukitow/7832731 to your computer and use it in GitHub Desktop.
Save chukitow/7832731 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<fstream>
using namespace std;
void determinarRangos(int[10], int);
int main()
{
int contador[10] = {0};
int rangos [10];
int extensionRango = 0;
int numero;
//Determinar los rangos de numeros
ifstream limites("C:\\Users\\Ivan Velasquez Rios\\Desktop\\Examen\\limites.txt");
if(!limites)
{
cout<<"Error"<<endl;
}
else
{
while (!limites.eof())
{
limites >> rangos[extensionRango];
extensionRango++;
}
rangos[extensionRango] = 100000;
limites.close();
}
ifstream numeros("C:\\Users\\Ivan Velasquez Rios\\Desktop\\Examen\\numeros.txt");
if(!numeros)
{
cout<<"Error al leer los numeros"<<endl;
}
else
{
while (!numeros.eof())
{
numeros >> numero;
bool ban = false;
int i=0;
while(ban==false)
{
if(numero<=rangos[i])
{
contador[i]++;
ban = true;
}
i++;
}
}
numeros.close();
}
for(int j=0;j<=extensionRango;j++)
{
cout<<"El numero del rango "<<j+1<<" se repite " << contador[j] << " tantas veces"<<endl;
}
cin.get();
cin.get();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment