Chcialbym wczytac 5 stringow, sprawdzic, czy są anagramami i jesli tak - wyrzucic je na wyjscie.
#include <string>
#include <stdio.h>
using namespace std;
bool sprs(string a, string b, string c, string d, string e)
{
if(a.size()==b.size()&&a.size()==c.size()&&a.size()==d.size()&&a.size()==e.size()) return 1;
}
void sort(string a)
{
for (int i = 0; i<a.size()-1; i++) if (a[i]>a[i+1]) swap(a[i], a[i+1]);
}
int main(int argc, char *argv[])
{
string a,b,c,d,e;
scanf("%s %s %s %s %s",a.c_str(), b.c_str(), c.c_str(), d.c_str(), e.c_str());
if(sprs(a, b, c, d, e))
{
sort(a);
sort(b);
sort(c);
sort(d);
sort(e);
if(a==b&&a==c&&c==d&&a==e) printf("%s %s %s %s %s\n",a.c_str(),b.c_str(),c.c_str(),d.c_str(),e.c_str());
}
return 0;
}
Program sie kompiluje, jednak po uruchomieniu i wprwadzeniu danych:
Process exited with return value 3221225477
Press any key to continue . . .