Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <stdio.h>
- #include <stdlib.h>
- 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; word[i]!=0; i++){
- if(word[i]== character){
- char *intStr = itoa(i);
- string str = string(intStr);
- key = key + str;
- /*string Result; // string which will contain the result
- stringstream convert; // stream used for the conversion
- convert << i; // insert the textual representation of 'Number' in the characters in the stream
- Result = convert.str(); // set 'Result' to the contents of the stream
- key = key + Result;
- cout << key;
- cout << Result;*/
- }
- }
- return key;
- }
- int main()
- {
- while(true)
- {
- string w;
- string key;
- char guess;
- cin >> w;
- cin >> guess;
- key = keyMaker(w, guess);
- cout << key<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement