Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- /**
- * 2)verif daca 2 vectori sunt anagrama unuia celuilalt
- */
- using namespace std;
- void arraySort(int *a, int n) {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (a[j] > a[i]) {
- int tmp = a[i];
- a[i] = a[j];
- a[j] = tmp;
- }
- }
- }
- }
- int main() {
- int a[100], b[100], n = 5;
- bool flag = true;
- for (int i = 0; i < n; i++)
- cin >> a[i];
- for (int i = 0; i < n; i++)
- cin >> b[i];
- arraySort(a, n);
- arraySort(b, n);
- for (int i = 0; i < n; i++)
- if (a[i] != b[i]) {
- flag = false;
- break;
- }
- if (flag)
- cout << "Sunt anagrame";
- else cout << "Nu sunt anagrame";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement