社区讨论

c语言re求帮QAQ

P10442「MYOI-R3」字符串参与者 4已保存回复 4

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@m3mr0h3e
此快照首次捕获于
2024/11/18 16:13
去年
此快照最后确认于
2025/11/04 14:28
4 个月前
查看原帖

代码实现:

C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void num(char* a, int *n) {
    for (int i = 0; i < strlen(a); i++) {
        n[a[i] - 'a']++;  
    }
}

int main() {
   
    char s[1002], t[1002];

   
    scanf("%s%s", s, t); 

   
    int a[26] = { 0 }, b[26] = { 0 };

   
    num(s, a);
    num(t, b);


    int sum = 0;
    for (int j = 0; j < 26; j++) {
      
        if (a[j] > b[j]) {
            a[j] = b[j];
        }
        sum += a[j];
    }

   
    printf("%d\n", sum);

    return 0;
}

回复

4 条回复,欢迎继续交流。

正在加载回复...