zoukankan      html  css  js  c++  java
  • A

    Problem description

    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.

    Examples

    Input

    HoUse

    Output

    house

    Input

    ViP

    Output

    VIP

    Input

    maTRIx

    Output

    matrix
    解题思路:题意很清楚,就是一个字符串中如果大写字母的个数小于或等于小写字母的个数,那么就全部换成小写字母;否则就全部换成大写字母,水过!
    AC代码:
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int main(){
     4     char s[105];int n1=0,n2=0;
     5     cin>>s;
     6     for(int i=0;s[i]!='';++i){
     7         if(s[i]>='A' && s[i]<='Z')n1++;
     8         else n2++;
     9     }
    10     if(n1<=n2){
    11         for(int i=0;s[i]!='';++i)
    12             if(s[i]>='A' && s[i]<='Z')s[i]+=32;
    13     }
    14     else{
    15         for(int i=0;s[i]!='';++i)
    16             if(s[i]>='a' && s[i]<='z')s[i]-=32;
    17     }
    18     cout<<s<<endl;
    19     return 0;
    20 }
  • 相关阅读:
    高性能网络编程2----TCP消息的发送
    高性能网络编程1----accept建立连接
    Android之怎样使用ListView列表视图
    创建hive整合hbase的表总结
    最新版本号cocos2d&#173;2.0&#173;x&#173;2.0.2使用新资源载入策略!不再沿用-hd、-
    在NSUserDefaults中保存自己定义的对象
    Light oj 1138
    一个NHibernate的BUG
    hbase exporter importer 导出 导入
    Gulp帮你自己主动搞定coffee和scss的compile
  • 原文地址:https://www.cnblogs.com/acgoto/p/9162131.html
Copyright © 2011-2022 走看看