venerdì 16 aprile 2010

C++ - Maggiore

// Rocco Meli, 16.064.2010
// Maggiore tra n numeri

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
// Dichiarazione variabili
int numeri;
int for1;
long double maggiore;
long double numero;
std::cout << "MAGGIORE" << std::endl;
std::cout << std::endl;
std::cout << "Quanti numeri vuoi inserire? ";
std::cin >> numeri;
std::cout << std::endl;
if (numeri <= 0
{
std::cout << "Non ci sono numeri" << std::endl;
}
else if (numeri == 1)
{
std::cout << "Inserire numero: ";
std::cin >> numero;
std::cout << std::endl;
maggiore = numero;
std::cout << "Il numero maggiore é " << maggiore << std::endl;
}
else // Numeri > 1
{
std::cout << "Inserire numero: ";
std::cin >> numero;
std::cout << std::endl;
maggiore = numero;
for (for1 = 1; for1 < numeri; for1++)
{
std::cout << "Inserire numero: ";
std::cin >> numero;
std::cout << std::endl;
if (numero > maggiore) 
{
maggiore = numero;
}
}
std::cout << "Il numero maggiore é " << maggiore << std::endl;
}
return 0;
}

Nessun commento: