1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
/*
* File: main.cpp
* Author: Melissa
*
* Created on den 12 december 2015, 19:38
*/
#include <cstdlib>
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string tweetArray[] = {"LOL","IRL","AFK","NVM","BFF","FTW","IIRC","TTYL","IMHO"};
string strArray[] = {"laughing out loud","in real life","away from keyboard","never mind","best friends forever","for the win", "if i recall correctly","talk to you later","in my honest opinon"};
string tweet2;
cout << "enter a tweet: " << endl;
getline(cin,tweet2);
int charnum = 0;
bool found = true;
int location = 0;
while (found){
if(location == 0){
location = tweet2.find(tweetArray[charnum]);
tweet2.replace(location,tweetArray[charnum].length(),strArray[charnum]);
} else {
location = tweet2.find(tweetArray[charnum],location);
tweet2.replace(location,tweetArray[charnum].length(),strArray[charnum]);
++charnum;
if(charnum >= 10){
found = false;
}
}
}
cout << tweet2;
return 0;
}
|