Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- struct toUpper{
- char operator()(char ch){
- return ch - 32;
- }
- };
- void printStr(string str){
- cout << str;
- }
- int main(){
- vector<string> data, functionResult, functorResult;
- string temp;
- while(cin >> temp){
- data.push_back(temp);
- }
- for(auto it = data.begin(); it != data.end(); it++){
- string str = *it;
- transform(str.begin(), str.end(), str.begin(), ::toupper);
- functionResult.push_back(str);
- }
- cout << "A)Function" << endl;
- for_each(functionResult.begin(), functionResult.end(), printStr);
- cout << endl;
- for(auto it = data.begin(); it != data.end(); it++){
- string str = *it;
- transform(str.begin(), str.end(), str.begin(), toUpper());
- functorResult.push_back(str);
- }
- cout << "B)Functor" << endl;
- for_each(functorResult.begin(), functorResult.end(), printStr);
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement