-
Transform
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ///////////////////////////////
-
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <string>
- using namespace std;
-
- int op_increase (int i)
- {
- return i+1;
- }
-
- int op_sum (int i, int j)
- {
- return i+j;
- }
-
- int to_upper(int c)
- {
- if (islower(c))
- {
- return (c-32);
- }
-
- return c;
- }
-
- int to_lower(int c)
- {
- if (isupper(c))
- {
- return c+32;
- }
-
- return c;
- }
-
- int main () {
- vector<int> first;
- vector<int> second;
- vector<int>::iterator it;
-
-
- for (int i=1; i<6; i++) first.push_back (i*10);
-
-
- second.resize(first.size());
- transform (first.begin(), first.end(), second.begin(), op_increase);
- cout << "second contains:";
- for (it=second.begin(); it!=second.end(); ++it)
- {
- cout << " " << *it;
- }
- cout << endl;
-
-
-
- transform (first.begin(), first.end(), second.begin(), first.begin(), op_sum);
- cout << "first contains:";
- for (it=first.begin(); it!=first.end(); ++it)
- cout << " " << *it;
- cout << endl;
-
-
-
- string strsrc("Hello, World!");
- string strdest;
- strdest.resize(strsrc.size());
- transform(strsrc.begin(), strsrc.end(), strdest.begin(), to_upper);
- cout << strdest << endl;
-
- transform(strsrc.begin(), strsrc.end(), strdest.begin(), to_lower);
- cout << strdest << endl;
-
-
- return 0;
- }
-
相关阅读:
Pyinstaller打包程序,运行时提示ModuleNotFoundError: No module named ‘pikepdf._cpphelpers’的解决办法
Tkinter设置askopenfilename通过filetypes指定只能打开某一种格式的文件时,不能打开文件选择器
Tkinter设置的回调函数程序运行自动执行,点击按钮没有执行回调函数
写Python爬虫遇到的一些坑
【Golang】【Lite IDE】Go语言环境安装及开发工具Lite IDE的安装
VUE--当前页面请求定时器,其他页面不需要
Cascader 级联选择器-------------子级全选则传父级, 子级未全选则传子级
数组去重
上传头像后导航栏中头像同步(Vue中监听sessionStorage)
ui-app打包创建新证书
-
原文地址:https://www.cnblogs.com/gaoxianzhi/p/3244110.html
Copyright © 2020-2023
润新知