首页 > 其他 > 详细

计蒜客练习题:蒜头君学英语

时间:2019-10-25 22:15:35      阅读:106      评论:0      收藏:0      [点我收藏+]

    技术分享图片技术分享图片

这里主要就是涉及到了一个string的大小写转换函数(在algorithm的库里):

        transform(first, last, result, op);

first是容器的首迭代器,last为容器的末迭代器,result为存放结果的容器,op为要进行操作的一元函数对象或sturct、class。

具体使用如下:

#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
 
using namespace std;
 
int main()
{
    string s = "Hello World";
    cout << s << endl;
    transform(s.begin(),s.end(),s.begin(),::toupper);//变大写
    cout << s << endl;
    transform(s.begin(),s.end(),s.begin(),::tolower);//变小写
   return 0; }

 

计蒜客练习题:蒜头君学英语

原文:https://www.cnblogs.com/Vikyanite/p/11740964.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!