Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //metoda 3
- //ce citesc 2 cuvinte
- //sa se verifice daca sunt anagrame(acela nr de litere, aceleasi litere care se repeta de acelas nr de ori)
- //ex: abba = aabb
- #include <iostream>
- using namespace std;
- int main()
- {
- int n1, n2, i, ok, aux;
- char a[100], b[100], *p, *i;
- cin>>a;
- cin>>b;
- n1=strlen(a);
- n2=strlen(b);
- if(n1 != n2)
- {
- cout << "nu sunt anagrame"<<"\n";
- return 0;
- }
- for(p = a; *p; p++)
- {
- ok=0;
- for(i = b; *i; i++)
- {
- if(*p == *i)
- {
- strcpy(i,i+1)
- ok=1;
- break;
- }
- }
- if(ok==0)
- {
- cout<<"nu sunt anagrame";
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement