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 }
  • 相关阅读:
    字符串函数---atof()函数具体解释及实现(完整版)
    curl的简单使用
    [7] 算法之路
    springMVC3.0(文件上传,@RequestMapping加參数,@SessionAttributes,@ModelAttribute,转发,重定向,数值获取,传參,ajax,拦截器)
    hdu 1754 I Hate It 线段树 点改动
    经典的7种排序算法 原理C++实现
    自己定义View实现水平滚动控件
    centos编译ffmpeg x264
    工作脚本处理文本
    A*寻路算法
  • 原文地址:https://www.cnblogs.com/acgoto/p/9162131.html
Copyright © 2011-2022 走看看