Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- const int MAX = 5;
- int a[MAX], b[MAX], c[MAX];
- bool presente_B = false, presente_C = false, nessun = true;
- srand(time(NULL));
- cout << "///////////////////" << endl << "A \tB \tC" << endl << endl;
- for( int i = 0; i < MAX; i++ )
- {
- a[i] = rand() % (rand() % 20 +1) + 1;
- b[i] = rand() % (rand() % 20 +1) + 1;
- c[i] = rand() % (rand() % 20 +1) + 1;
- cout << a[i] << "\t" << b[i] << "\t" << c[i] << endl << endl;
- }
- for( int i = 0; i < MAX; i++)
- {
- for( int j = 0; j < MAX && !presente_B; j++)
- {
- if( a[i] == b[j] )
- {
- presente_B = true;
- }
- }
- for( int j = 0; j < MAX && !presente_C; j++)
- {
- if( a[i] == c[j] )
- {
- presente_C = true;
- }
- }
- if( presente_C && presente_B )
- {
- cout << endl << "/// Il Numero -> " << a[i] << " appare in tutti e tre gli array ///" << endl;
- nessun = false;
- }
- presente_C = false;
- presente_B = false;
- }
- if( nessun )
- {
- cout << endl << "/// Nessun numero viene ripetuto nei tre array :'( ///" << endl;
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement