Anonymous user
Semordnilap: Difference between revisions
m
→{{header|C++}}: little code reduction
m (added related tasks.) |
m (→{{header|C++}}: little code reduction) |
||
Line 551:
#include <string>
int main() {
std::ifstream input("unixdict.txt");
if (
}▼
size_t count = 0; // pair count▼
▲ std::set<std::string> words; // previous words
std::string drow(word.rbegin(), word.rend()); //
if (words.find(drow) == words.end()) {
▲ size_t count = 0; // pair count
std::cout << word << ' ' << drow << '\n';▼
▲ } else { // pair found
▲ if (count < 5) {
▲ std::cout << word << ' ' << drow << '\n';
}
▲ ++count;
}
std::cout << "\nSemordnilap pairs: " << count << '\n';▼
return 0;
▲ std::cout << "\nSemordnilap pairs: " << count << '\n';
▲ } else
return 1; // couldn't open input file
}</lang>
{{out}}
|