Solução: Problema da palavra mágica (Marco Antonio)

From AdonaiMedrado.Pro.Br
Revision as of 14:28, 20 May 2009 by 200.17.147.2 (Talk) (New page: <code lang="cpp"> #include <iostream> #include <string> #include <algorithm> using namespace std; bool compare(char chara, char charb) { return (chara < charb); } int main() { string ...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
bool compare(char chara, char charb)
{
	return (chara < charb);
}
 
int main()
{
	string entry, word;
 
	cin >> entry;
	if (entry.length() % 2 == 0){
		word = entry.substr(0, (entry.length()/2));
		entry = entry.substr(entry.length()/2, entry.length());
		sort(word.begin(),word.end(),compare);
		cout << word << "\n" << entry << endl;
		if (!(entry.compare(word)))
			cout << "S" << endl;
		else
			cout << "N" << endl;
	}
	else
		cout << 'N' << endl;
 
	return 0;
}