The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Anagram Awesome!
Posted by: Robert | November 19, 2010 @ 1:52am
C++ Code
[
Download
]
#include <iostream> #include <string> using namespace std; bool isAnagram(const string &str1, const string &str2); int main() { string mystringOne; string mystringTwo; cout << "ANIGRAM MACHINE" << endl << endl; cout << "Enter word one --> "; cin >> mystringOne; cout << "Enter Word two --> "; cin >> mystringTwo; cout << endl; if(isAnagram(mystringOne,mystringTwo)) { cout << mystringOne << " and " << mystringTwo << " are anagrams!" << endl; } else { cout << mystringOne << " and " << mystringTwo << " are NOT anagrams!" << endl; } return 0; } bool isAnagram(const string &s1, const string &s2) { for(int i = 0; i < s1.length(); i++) { if(s2.find(s1[i]) == string::npos) { return false; } if(s1.find(s2[i]) == string::npos) { return false; } } if(s1 == s2) return true; return true; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.44 / 8
25 Votes