关于一些初级ACM竞赛题目的分析和题解(十)

关于一些初级ACM竞赛题目的分析和题解(十) 

   西面的题目是关于一些字母变换的,上题:

A. Word
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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

输入
第一行包含一个单词s - 由大写和小写拉丁字母组成,长度从1到100。
输出
打印纠正的单词s。 如果给定的单词s具有更多的大写字母,则将该单词写入大写寄存器中,否则  以小写字母写入。

题意即一行字符串若是大写字母数大于小写字母数则把这一行字符变为大写,反之,变为小写,下面是代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int l,c,b;
int main()
{
    char a[300];

    scanf("%s",a);
    l=strlen(a);
    for (int i=0;i<l;i++)
        {
        if(a[i]>=97)c++;  //不同类型计数
        else b++;
        }
    if (c>=b)  // 比较大小写的字符数目
    {
        for (int j=0;j<l;j++)
            if(a[j]<97)a[j]+=32;  //执行
        return 0*printf("%s",a);
    }
        if (c<b)
    {
        for (int j=0;j<l;j++)
            if(a[j]>=97)a[j]-=32;
        return 0*printf("%s",a);  //  输出结果
    }


}








ACM/ICPC(ACM International Collegiate Programming Contest, 国际大学生程序设计竞赛)是由国际计算机界历史悠久、颇具权威性的组织ACM(Association for Computing Machinery,国际计算机协会)主办的,世界上公认的规模最大、水平最高的国际大学生程序设计竞赛,其目的旨在使大学生运用计算机来充分展示自己分析问题解决问题的能力。该项竞赛从1970年举办至今已历29届,一直受到国际各知名大学的重视,并受到全世界各著名计算机公司的高度关注,在过去几年中,APPLE、AT&T、MICROSOFTIBM等世界著名信息企业分别担任了竞赛的赞助商。可以说,ACM国际大学生程序设计竞赛已成为世界各国大学生最具影响力的国际级计算机类的赛事,是广大爱好计算机编程的大学生展示才华的舞台,是著名大学计算机教育成果的直接体现,是信息企业与世界顶尖计算机人才对话的最好机会。   该项竞赛分区域预赛国际决赛两个阶段进行,各预赛区第一名自动获得参加世界决赛的资格,世界决赛安排在每年的3~4月举行,而区域预赛安排在上一年的9~12月在各大洲举行。   ACM/ICPC的区域预赛是规模很大、范围很广的赛事。仅在2003年参加区域预赛的队伍就有来自75个国家(地区),1411所大学的3150支代表队,他们分别在127个赛场中进行比赛,以争夺全球总决赛的73个名额,其激烈程度可想而知。 2005年第30届ACM/ICPC亚洲赛区预赛共设了北京、成都、汉城、东京等11个赛站,来自亚洲各国知名高校的各个代表队进行了激烈的角逐。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值