Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int
- main ()
- {
- int vet1[10], vet2[10], counter[10];
- for (int i = 0; i < 10; i++)
- {
- counter[i] = 0;
- }
- cout << "Inizio input" << endl;
- for (int i = 0; i < 10; i++)
- {
- cin >> vet1[i];
- }
- cout << "fine vettore 1" << endl;
- for (int i = 0; i < 10; i++)
- {
- cin >> vet2[i];
- }
- cout << "fine vettore 2" << endl;
- cout << "Verifico presenze comuni" << endl;
- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < 10; j++)
- if (vet1[i] == vet2[j])
- {
- cout << vet1[i];
- break;
- }
- }
- cout << endl << "Numero maggiormente presente" << endl;
- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < 10; j++)
- if (vet1[i] == vet2[j])
- {
- counter[i]++;
- }
- }
- int max_index = 0;
- for (int i = 0; i < 10; i++)
- {
- if (counter[i] > max_index)
- max_index = i;
- }
- cout << vet1[max_index];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement