#12292. 珅泽教育CSP-J第一轮模拟考第二十五套 第 20 题

珅泽教育CSP-J第一轮模拟考第二十五套 第 20 题

二、阅读程序(程序一)

#include <cstdio>
#include <cstring>

using namespace std;

char s[10000];
int cnt[26];

int main() {
    scanf("%s", s);
    for (int i = 0; i < strlen(s); ++i) {
        if (cnt[s[i] - 'a'] <= 50) {
            s[strlen(s)] = s[i];
        }
        ++cnt[s[i] - 'a'];
    }
    printf("%s\n", s);
    return 0;
}

假设初始时输入的字符串长度不超过 500,且不是空串。

  1. 设输入字符串长度为 x(1x500)x (1\le x\le 500),输出字符串长度为 yy,则关于 x,yx,y 的关系正确的是( )。

{{ select(1) }}

  • 对全部输入字符串都有 x=yx=y
  • 对全部输入字符串都有 x<yx<y
  • 有些输入满足 x=yx=y,有些满足 x<yx<y,但不存在 x>yx>y
  • 有些输入满足 x=yx=y,有些满足 x>yx>y,还有些满足 x<yx<y