【每日编程-437期】西北农林科技大学上机题(四)

教育   2025-02-04 10:01   江西  

西北农林科技大学上机题(四)


每日编程中遇到任何疑问、意见、建议请公众号留言或加入每日编程群聊739635399



输入一个字符串,统计字符串中大、小写字母,数字及其他字符出现的次数

输入样例:

abcd123![]ABC

输出样例:

3 4 3 3

解决方法:

(1)代码实现:

#include <stdio.h>
int main() {
  char chuan[1000];
  scanf("%s", chuan);
  int big = 0, small = 0, number = 0, other = 0, i = 0;
  for (; chuan[i] != 0; ++i) {
    if (chuan[i] > 64 && chuan[i] < 91) {
      big = big + 1;
      continue;
    }
    if (chuan[i] > 96 && chuan[i] < 123) {
      small = small + 1;
      continue;
    }
    if (chuan[i] > 47 && chuan[i] < 58) {
      number = number + 1;
      continue;
    }
    other = other + 1;
  }
  printf("%d ", big);
  printf("%d ", small);
  printf("%d ", number);
  printf("%d\n", other);
  return 0;
}

明日预告:浙江大学上机题(一)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.

输入格式:

Each input file contains one test case. For each case, the first line gives a positive integer N (), which is the number of testees. Then N lines follow, each gives the information of a testee in the following format:

ID Score School

输出格式:

For each case, first print in a line the total number of institutions. Then output the ranklist of institutions in nondecreasing order of their ranks in the following format:

Rank School TWS Ns

where Rank is the rank (start from 1) of the institution; School is the institution code (all in lower case); ; TWS is the total weighted score which is defined to be the integer part of ScoreB/1.5 + ScoreA + ScoreT*1.5, where ScoreX is the total score of the testees belong to this institution on level X; and Ns is the total number of testees who belong to this institution.

The institutions are ranked according to their TWS. If there is a tie, the institutions are supposed to have the same rank, and they shall be printed in ascending order of Ns. If there is still a tie, they shall be printed in alphabetical order of their codes.

输入样例:

10
A57908 85 Au
B57908 54 LanX
A37487 60 au
T28374 67 CMU
T32486 24 hypu
A66734 92 cmu
B76378 71 AU
A47780 45 lanx
A72809 100 pku
A03274 45 hypu

输出样例:

5
1 cmu 192 2
1 au 192 3
3 pku 100 1
4 hypu 81 2
4 lanx 81 2


灰灰考研
最全的【计算机考研】【软件考研】考研信息! 最丰富的共享资料! 最大程度上帮助学渣狗登上研究生大门!
 最新文章