Untitled
unknown
plain_text
a year ago
2.1 kB
2
Indexable
#include <iostream> #include <algorithm> using namespace std; int main() { int a[10], b[10]; int eshterak = 0; int faghat_aval = 0; int ejtema[20]; int ej_size = 0; for (int i = 0; i < 10; i++) { cin >> a[i]; } for (int i = 0; i < 10; i++) { cin >> b[i]; } sort(a, a+10); sort(b, b+10); for (int i = 0; i < 10; i++) { if (a[i] != a[i-1] || i == 0){ bool found = false; for (int j = 0; j < 10; j++) { if (a[i] == b[j]) { found = true; break; } } if (!found) { faghat_aval++; } } } // eshterak for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (a[i] != a[i-1] && b[j] != b[j-1] || i == 0 || j == 0){ if (a[i] == b[j]) { eshterak++; break; } } } } //ejtema for (int i = 0; i < 10; i++) { bool found = false; for (int j = 0; j < ej_size; j++) { if (ejtema[j] == a[i]) { found = true; break; } } if (!found) { ejtema[ej_size++] = a[i]; } } for (int i = 0; i < 10; i++) { bool found = false; for (int j = 0; j < ej_size; j++) { if (ejtema[j] == b[i]) { found = true; break; } } if (!found) { ejtema[ej_size++] = b[i]; } } // sort(ejtema, ejtema + ej_size); // cout cout << faghat_aval << endl; cout << eshterak << endl; for (int i = 0; i < ej_size; i++) { if (i > 0) { cout << " "; } cout << ejtema[i]; } cout << endl; return 0; }
Editor is loading...
Leave a Comment