游客 Signup | Login
中文 | En

3410 - 考试三字符操作

输入N个字母字符串,要求小写变大写,大写变小写输出,并统计其中大写字母的个数,小写字母的个数输出;(N<=100)

Input

输入包含大小写字母的字符串HElloWorld

Output

将大写字母转换成小写,小写反之,输出;并输出转换后的大写字母个数以及小写字母个数

Examples

Input

HElloWorld

Output

heLLOwORLD
7 3 

Solution C

#include<stdio.h>
#include<string.h>
int main()
{
	char str[80];
	int len,i,a=0,b=0;
	gets(str);
	len=strlen(str);
	for(i=0;i<len;i++)
	{
		if (('A'<=str[i])&&(str[i]<='Z'))
		{
			str[i]=str[i]+32,a++;
		}
		else if (('a'<=str[i])&(str[i]<='z'))
		{
			str[i]=str[i]-32,b++;
		}
	}
	puts(str);
	printf("%d %d",b,a);
	return 0;
}

Solution C++

#include <iostream>
#include <string>
using namespace std;
int main()
{
	int big = 0, small = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] >= 'A' && s[i] <= 'Z')
		{
			small++;
			s[i] += 32;
		}
		else
		{
			big++;
			s[i] -= 32;
		}
	}
	cout << s << endl;
	cout << big << ' ' << small << endl;
	return 0;
}

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题