codeforces——59A——Word
来源:互联网 发布:剑灵灵女捏脸数据下载 编辑:程序博客网 时间:2024/06/17 02:44
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 wordHoUse 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.
The first line contains a word s — it consists of uppercase and lowercase Latin letters and possesses the length from1 to 100.
Print the corrected word s. If the given words has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one.
HoUse
house
ViP
VIP
maTRIx
matrix水题。小写字母数量大于等于大写字母数量,则全部小写,否则全部大写。#include<stdio.h>#include<iostream>#include<cstring>#include<cmath>#include<algorithm>#include<map>using namespace std;int main(){ char s[108]; while(~scanf("%s",s)) { int n=strlen(s),big=0,small=0; for(int i=0; i<n; i++) if(s[i]>=97) small++; else big++; if(small>=big) { for(int i=0; i<n; i++) if(s[i]<97) s[i]+=32; } else for(int i=0; i<n; i++) if(s[i]>=97) s[i]-=32; cout<<s<<endl; } return 0;}
- codeforces——59A——Word
- Codeforces刷题之路——281A Word Capitalization
- 【codeforces #3】A——BFS+贪心
- Codeforces —— 359A Table
- codeforces 365A——Good Number
- codeforces——A. Counting Sticks
- codeforces——1A - Theatre Square
- CodeForces—301A—Combination Lock
- codeforces#575A——Fibonotci
- 搜索——Codeforces 763A
- codeforces 804A——Find Amir
- 递推——Codeforces 319A
- CodeForces 698A—Vacations(贪心)
- Educational Codeforces Round 26 A—C
- codeforces——732A——Buy a Shovel
- CodeForces-281A-Word Capitalization
- codeforces 281A Word Capitalization
- 第八周周赛——复习题解(出自codeforces 633A,610A,poj2155,poj3070,codeforces 538B,codeforces 513A)
- 第十届河南省赛 问题 A: 谍报分析(以文本结束)
- 如何学习现代化前端
- UVa 10004 Bicoloring(二分图判定+DFS)
- [leetcode]152. Maximum Subarray
- 第五章数理统计--样本和抽样分布
- codeforces——59A——Word
- Windows下简单快速搭建Flask开发环境
- 【图论】[SCOI2005]繁忙的都市
- git的沉淀
- 69. Sqrt(x)
- Docker
- SVN 基础记录
- 编码心得
- 数组,对象遍历以及特殊的数组里的对象处理