Word

末蓝、 2022-08-10 05:58 254阅读 0赞

Word

Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^

题目描述

Tom is very upset that many people on the internet 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.

输入

The first line of input contains an integers T, indicating T test case will follow.Each of the next T lines contains a word s — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100.

输出

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.

示例输入

  1. 3
  2. HoUse
  3. ViP
  4. maTRIx

示例输出

  1. house
  2. VIP
  3. matrix

提示

来源

示例程序

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<ctype.h>
  4. char a[10000];
  5. int main()
  6. {
  7. int i,j,n,m,t,k;
  8. scanf("%d",&n);
  9. for(i=0;i<n;i++)
  10. {
  11. k=0;
  12. t=0;
  13. scanf("%s",a);
  14. m=strlen(a);
  15. for(j=0;j<m;j++)
  16. {
  17. if(islower(a[j]))
  18. k++;
  19. if(isupper(a[j]))
  20. t++;
  21. }
  22. if(k>=t)
  23. for(j=0;j<m;j++)
  24. a[j]=tolower(a[j]);
  25. else
  26. for(j=0;j<m;j++)
  27. a[j]=toupper(a[j]);
  28. printf("%s\n",a);
  29. }
  30. }

发表评论

表情:
评论列表 (有 0 条评论,254人围观)

还没有评论,来说两句吧...

相关阅读

    相关 word-wrap和word-break

    word-wrap: css的 word-wrap 属性用来标明是否允许浏览器在单词内进行断句,这是为了防止当一个字符串太长而找不到它的自然断句点时产生溢出现象。 word

    相关 hello word

    建立一个文件夹 建立个java文件 后缀是.java Hellow.java java是大小写敏感的 文件的名字和class后面的名字要一致 都是在英文状态

    相关 Word

    Word Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^\_^ 题目描述 Tom is very upse