3
An algorithm that reads 15 real numbers, and writes the largest and the smallest among the numbers read. I’m not getting to do the part of writing the smallest and largest of the numbers typed.
Code:
#include <iostream>
using namespace std;
int main(){
float numero;
int cont;
cont=1;
while(cont<=15) {
cout << ("Digite um numero real:");
cin >> numero;
cont++;
}
}
How to get the highest and lowest number among the typed numbers?
Define the variables
maior
andmenor
, after reading a do:if (cont == 1) menor = maior = num; else {if (num > maior) maior = num; if (num < menor) menor = num;}
. After the loop print the variablesmaior
andmenor
.– anonimo
@anonymity would not be better to use the
std::set
or avector
with thealgorithm
?– Codigo de Senior
I was following the line that diogoBRRN was following in the development and he was not using such Features and there is possible solution without using them..
– anonimo