Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<cctype>
- using namespace std;
- void swap(char& v1, char & v2);
- //Interchanges the value of v1 and v2
- string remove(const string& s);
- //Return a copy of s but with extra whitespace removed.
- string maeUpper(const string &s);
- //Return a copy of s that has all lowercase
- // charachters change to uppercase, with other characters unchanged.
- int main()
- {
- string str;
- cout << "Please enter a sentances to be correcter\n"
- << "followed by pressing Return.\n";
- getline(cin, str);
- system("pause");
- return 0;
- }
- void swap(char & v1, char& v2)
- {
- char temp = v1;
- v1 = v2;
- v2 = temp;
- }
- string remove(const string& s)
- {
- int start = 0;
- int end = s.length();
- string temp(s);
- {
- end--;
- swap(temp[start], temp[end]);
- }
- return temp;
- }
- //Uses <cctype> and <string>
- string makeUpper(const string &s)
- {
- string temp(s);
- for (int i = 0; i < s.length();i++)
- temp[i] = toupper(s[i]);
- return temp;
- }
- string remove(const string& s, const string punct)
- {
- string noPunct; //Initialize to empty string
- int sLenght = s.length();
- int punctLenght = punct.length();
- for (int i = 0; i < sLenght;i++)
- {
- string aChar = s.substr(i, 1); // A one-charachter string
- int location = punct.find(aChar, 0);
- //Find location of successive charcters
- //of src in punct.
- if (location < 0 || location >= punctLenght)
- noPunct = noPunct + aChar; //aChar is not in punct, so keep it
- }
- return noPunct;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement