CodeForces 59A Word 水题
2017-01-23 16:43
507 查看
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted
of lowercase letters or, vice versa, only of uppercase ones. At that as little as possible letters should be changed in the word. For example, the word HoUse must be replaced with house,
and the word ViP — with VIP. If a word contains an equal number of uppercase and lowercase letters, you should replace all the letters with lowercase ones. For example, maTRIx should
be replaced by matrix. Your task is to use the given method on one given word.
Input
The first line contains a word s — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100.
Output
Print the corrected word s. If the given word s has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one.
Example
Input
Output
Input
Output
Input
Output
判断大小写字母
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi 3.1415927
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}
//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
string s;
int ct1,ct2;
int main()
{
ios::sync_with_stdio(false);
cin >> s;
for(int i=0;i<s.size();i++)
{
if(s[i]>='A'&&s[i]<='Z')
ct1++;
else
ct2++;
}
if(ct1>ct2)
{
for(int i=0;i<s.size();i++)
{
if(s[i]>='a'&&s[i]<='z')
s[i]-=32;
}
}
else
{
for(int i=0;i<s.size();i++)
{
if(s[i]>='A'&&s[i]<='Z')
s[i]+=32;
}
}
cout<<s<<endl;
return 0;
}
of lowercase letters or, vice versa, only of uppercase ones. At that as little as possible letters should be changed in the word. For example, the word HoUse must be replaced with house,
and the word ViP — with VIP. If a word contains an equal number of uppercase and lowercase letters, you should replace all the letters with lowercase ones. For example, maTRIx should
be replaced by matrix. Your task is to use the given method on one given word.
Input
The first line contains a word s — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100.
Output
Print the corrected word s. If the given word s has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one.
Example
Input
HoUse
Output
house
Input
ViP
Output
VIP
Input
maTRIx
Output
matrix
判断大小写字母
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi 3.1415927
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}
//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
string s;
int ct1,ct2;
int main()
{
ios::sync_with_stdio(false);
cin >> s;
for(int i=0;i<s.size();i++)
{
if(s[i]>='A'&&s[i]<='Z')
ct1++;
else
ct2++;
}
if(ct1>ct2)
{
for(int i=0;i<s.size();i++)
{
if(s[i]>='a'&&s[i]<='z')
s[i]-=32;
}
}
else
{
for(int i=0;i<s.size();i++)
{
if(s[i]>='A'&&s[i]<='Z')
s[i]+=32;
}
}
cout<<s<<endl;
return 0;
}
相关文章推荐
- codeforces——59A——Word
- Codeforces 426 B Sereja and Mirroring【暴力枚举+模拟】水题
- codeforces水题100道 第十二题 Codeforces Beta Round #91 (Div. 2 Only) A. Lucky Division (brute force)
- codeforces水题100道 第二十二题 Codeforces Beta Round #89 (Div. 2) A. String Task (strings)
- codeforces水题100道 第二十三题 Codeforces Beta Round #77 (Div. 2 Only) A. Football (strings)
- CodeForces 560B Gerald is into Art【水题】
- CodeForces 689A Mike and Cellphone (模拟+水题)
- 【打CF,学算法——一星级】CodeForces 701A Cards(水题)
- 2016 北邮暑期训练3-D题(Codeforces 698A Vacations)DP,水题
- 733B Parade codeforces(水题)
- Codeforces 450A Jzzhu and Children(水题)
- Codeforces 401A Vanya and Card【贪心】水题
- Codeforces 365(Div.2)A.Mishka and Game【水题】
- Codeforces 598B Queries on a String 【水题】
- codeforces 665A A. Buses Between Cities(水题)
- Palindrome Transformation - CodeForces 486 C 水题
- 【Codeforces 176B】 Word Cut
- CodeForces 711A Bus to Udayland(水题)
- CodeForces 711A Bus to Udayland (水题)
- CodeForces 670B(模拟)水题