将字符串中的小写字母转换成大写字母

将字符串中的小写字母转换成大写字母


时间限制: 1000 ms         内存限制: 65536 KB
提交数: 545     通过数: 271 

【题目描述】

给定一个字符串,将其中所有的小写字母转换成大写字母。

【输入】

输入一行,包含一个字符串(长度不超过100,可能包含空格)。

【输出】

输出转换后的字符串。

【输入样例】

helloworld123Ha

【输出样例】

HELLOWORLD123HA

【来源】


No

【代码】

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cctype>
#include<cmath>
using namespace std;
char a[100];
int la,i;
int main()
{
gets(a);
la=strlen(a);
for(i=0;i<la;i++)
{
if(islower(a[i]))//判断是否为小写字母
a[i]=toupper(a[i]);//将小写字母转换为大写字母
}
for(i=0;i<la;i++)//输出
cout<<a[i];
cout<<endl;
return 0;
}

【说明】

提交通过,vc6.0运行成功
将字符串中的小写字母转换成大写字母