Você está na página 1de 4

TRABALHO

1)#include <iostream>
using namespace std;

int main() {
int maior = INT_MIN, menor = INT_MAX;
for (int i = 0; i < 500; i++) {
int num;
cin >> num;
if (num > maior) maior = num;
if (num < menor) menor = num;
}
cout << "Maior valor: " << maior << endl;
cout << "Menor valor: " << menor << endl;
return 0;
}

2) #include <iostream>
using namespace std;
int main() {
int n = 50;
double maior = -1, menor = 1000,
soma_altura_mulheres = 0, cont_mulheres =
0, cont_homens = 0;
for (int i = 0; i < n; i++) {
double altura;
char sexo;
cin >> altura >> sexo;
if (altura > maior) maior = altura;
if (altura < menor) menor = altura;
if (sexo == 'F') {
soma_altura_mulheres += altura;
cont_mulheres++;
} else if (sexo == 'M') {
cont_homens++;
}
}
cout << "Maior altura: " << maior << endl;
cout << "Menor altura: " << menor << endl;
cout << "Média de altura das mulheres: "
<< soma_altura_mulheres / cont_mulheres
<< endl;
cout << "Número de homens: " <<
cont_homens << endl;
return 0;
}
3) #include <iostream>
using namespace std;

int main() {
int n = 2000;
int votos[4] = {0};
for (int i = 0; i < n; i++) {
int voto;
cin >> voto;
votos[voto]++;
}
cout << "Votos do candidato 1: " <<
votos[1] << endl;
cout << "Votos do candidato 2: " <<
votos[2] << endl;
cout << "Votos do candidato 3: " <<
votos[3] << endl;
int mais_votado = 1;
for (int i = 2; i <= 3; i++) {
if (votos[i] > votos[mais_votado])
mais_votado = i;
}
cout << "Candidato mais votado: " <<
mais_votado << endl;
return 0;
}

Você também pode gostar