43 lines
834 B
C++
43 lines
834 B
C++
#include <iostream>
|
|
#include <ctime>
|
|
#include <cstdlib>
|
|
|
|
#define NUM_MIN 0
|
|
#define NUM_MAX 10
|
|
|
|
using namespace std;
|
|
|
|
typedef struct {
|
|
int n1, n2;
|
|
} numeriDaSommare;
|
|
|
|
numeriDaSommare riempi();
|
|
void calcolo(int n1, int n2);
|
|
void stampa(int n1, int n2);
|
|
|
|
int main(void) {
|
|
srand(time(NULL));
|
|
|
|
numeriDaSommare numero = riempi();
|
|
stampa(numero.n1, numero.n2);
|
|
calcolo(numero.n1, numero.n2);
|
|
|
|
return 0;
|
|
}
|
|
|
|
numeriDaSommare riempi() {
|
|
numeriDaSommare numero;;
|
|
numero.n1 = rand() % (NUM_MAX - NUM_MIN + 1) + NUM_MIN;
|
|
numero.n2 = rand() % (NUM_MAX - NUM_MIN + 1) + NUM_MIN;
|
|
|
|
return numero;
|
|
}
|
|
|
|
void calcolo(int n1, int n2) {
|
|
cout << "Somma: " << n1 + n2 << endl;
|
|
}
|
|
|
|
void stampa(int n1, int n2) {
|
|
cout << "Primo numero: " << n1 << endl;
|
|
cout << "Secondo numero: " << n2 << endl << endl;
|
|
} |