Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void printLowerOrUppreCase(string* str, bool(*caseProcesses)(char&))
- {
- char ch;
- for (int i = 0; i < str->length(); i++)
- {
- ch = str->at(i);
- if (caseProcesses(ch))
- str->replace(i, 1, 1, ch);
- }
- cout << str[0];
- }
- bool lowerCase(char& ch)
- {
- if (ch >= 'A' && ch <= 'Z')
- {
- ch += 32;
- return true;
- }
- return false;
- }
- bool upperCase(char& ch)
- {
- if (ch >= 'a' && ch <= 'z')
- {
- ch -= 32;
- return true;
- }
- return false;
- }
- int main()
- {
- string input;
- getline(cin, input);
- string copy = input;
- printLowerOrUppreCase(©, lowerCase);
- cout << endl;
- printLowerOrUppreCase(&input, upperCase);
- }
Advertisement
Add Comment
Please, Sign In to add comment