Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- string keyMaker(string word, char character){ // makes a unique key based on the occurences of letters
- string key;
- for(int i= 0; i < word.length(); i++){
- if(word[i]== character){
- //key = key + i + "-" ; // - added each time letter is found
- stringstream ss;
- ss << i;
- key = key + "-" + ss.str();
- }
- }
- return key;
- }
- int main()
- {
- while(true)
- {
- string w;
- string k;
- char guess;
- cin >> w;
- cin >> guess;
- k = keyMaker(w, guess);
- cout << k <<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment