C++ Primer(第五版)练习6.17

来源:互联网 发布:json是转换是什么 编辑:程序博客网 时间:2024/06/06 05:41
#include <iostream>#include <string>#include <vector>using namespace std;int judge(const string &a)//判断是否有大写{for (auto &b : a){if (b >= 65 && b <= 90){return 1;break;}elsereturn 0;}}void change(string &a)//大写转小写{for (auto &b : a)b = toupper(b);}int main() {string s("Hello World");int j;j = judge(s);if (j){cout << "Y" << endl;change(s);}elsecout << "N" << endl;cout << s << endl;system("pause");return 0;}

0 0