字符串大小写转换

 1 #include<stdafx.h>
 2 #include<iostream>
 3 #include<string>
 4 #include <algorithm> 
 5 
 6 using namespace std;
 7 
 8 int main(void)
 9 {
10     //string str;
11     char ch;
12     int len = 0, count = 0;
13     string str = "abcdefghijklnmopqrstuvwxyz123";
14     transform(str.begin(), str.end(), str.begin(), toupper);
15     cout << str << endl;
16     //while (getline(cin, str) && cin >> ch)
17     //{
18     //    len = str.length();
19     //    for (int i = 0; i < len; i++)
20     //    {
21     //        if (str[i] >= 'a'&&str[i] <= 'z')
22     //        {
23     //            str[i] += ('A' - 'a');
24     //        }
25     //    }
26     //    if (ch >= 'a' && ch <= 'z')
27     //    {
28     //        ch += ('A' - 'a');
29     //    }
30     //    for (int i = 0; i < len; i++)
31     //    {
32     //        if (str[i] == ch)
33     //        {
34     //            count++;
35     //        }
36     //    }
37     //    cout << count << endl;
38     //}
39 
40     
41     return 0;
42 }

 

posted @ 2016-05-24 10:03  hhboboy  阅读(367)  评论(0编辑  收藏  举报