Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string a, b, words; // Skilgreina strengina sem ég þarf að nota.
- unsigned int pos = 0;
- cin >> a >> b; // Orðin, sem breyturnar a og b.
- getline(cin,words);
- pos = words.find(a);
- for (unsigned int i = 0; i < words.length(); i++)
- {
- if (pos < words.length())
- {
- if (i == 0)
- {
- words.erase(pos, a.length());
- words.insert(pos, b);
- pos = words.find(a, pos + a.length());
- }
- else
- {
- words.erase(pos, a.length());
- words.insert(pos, b);
- pos = words.find(a, pos + a.length());
- }
- {
- pos = words.find_first_of(" ");
- while (pos < (words.length()-1))
- {
- if(isalpha(words[pos+1]))
- {
- words[pos+1] = toupper(words[pos + 1]);
- }
- pos = words.find_first_of(" ", pos + 1);
- }
- cout << words << endl;
- }
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement