Created
December 11, 2013 13:32
-
-
Save joepreludian/7910496 to your computer and use it in GitHub Desktop.
Segundo exercício da lista de exercícios da professora Eliselma.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 1) Intervalos | |
// | |
// Lê um número não conhecido de valores, um de cada vez, e conta quantos deles estão em cada um dos intervalos | |
// [0; 25), [25; 50), [50; 75) e [75; 100] | |
// | |
#include <iostream> | |
using namespace std; | |
int main(int argc, const char * argv[]) | |
{ | |
cout << "Digite numeros.\nDigitar um número negativo encerra a captura.\n\n"; | |
int intervalos[4] = {0,0,0,0}; | |
int contador = 0; | |
int numero = 0; | |
while (true) { | |
cin >> numero; | |
if (numero < 0) { | |
break; | |
} | |
if (numero >= 0 and numero < 25) { | |
intervalos[0]++; | |
} | |
if (numero >= 25 and numero < 50) { | |
intervalos[1]++; | |
} | |
if (numero >= 50 and numero < 75) { | |
intervalos[2]++; | |
} | |
if (numero >=75 and numero <= 100) { | |
intervalos[3]++; | |
} | |
contador++; | |
} | |
for (int i=0; i<4; i++) { | |
cout << "Ocorrencia do " << (i+1) << "o intervalo: "; | |
cout << ((intervalos[i]*100)/contador) << "%\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment