Upload files to "funzioni"
This commit is contained in:
parent
6ec0fbe583
commit
2aa83f2510
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
AUTORE: Manuel Vichi
|
||||
Funzione segno
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
using namespace std;
|
||||
signed int sign(int number) {
|
||||
if (number > 0)
|
||||
return +1;
|
||||
else if (number == 0)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
int main() {
|
||||
signed int numero;
|
||||
cout << "Inserisci un numero: ";
|
||||
cin >> numero;
|
||||
cout << endl << "Ricorda: La funzione segno stampa -1 se il numero e' negativo e +1 se il numero e' positivo." << endl << "Risultato della funzione segno: " << sign(numero) << endl;
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
AUTORE: Manuel Vichi
|
||||
Lati di un triangolo
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
using namespace std;
|
||||
bool isTriangle(int ab, int bc, int ca) {
|
||||
if (ab + bc > ca && bc + ca > ab && ca + ab > bc)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
int main() {
|
||||
int ab, bc, ca;
|
||||
cout << "Inserisci il primo lato: ";
|
||||
cin >> ab;
|
||||
cout << endl;
|
||||
cout << "Inserisci il secondo lato: ";
|
||||
cin >> bc;
|
||||
cout << endl;
|
||||
cout << "Inserisci il terzo lato: ";
|
||||
cin >> ca;
|
||||
cout << endl;
|
||||
if (isTriangle(ab,bc,ca))
|
||||
cout << "Le misure date in input potrebbero corrispondere a misure dei lati di un eventuale triangolo." << endl;
|
||||
else
|
||||
cout << "Le misure date in input non possono corrispondere a misure dei lati di un triangolo." << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue