c语言re求帮QAQ
查看原帖
c语言re求帮QAQ
1503571
Hoshimati楼主2024/11/18 16:11

代码实现:

#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;
}
2024/11/18 16:11
加载中...