The 9th Zhejiang Provincial Collegiate Programming Contest->Problem D:D

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3603
题意:在给出的字符串中找出每行都出现的字母按字典序排序。

#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--) {
        int num[107],num1[107];
        char s[107];
        int n;
        cin>>n;
        memset(num,0x3f3f3f3f,sizeof(num));
        memset(num1,0,sizeof(num1));
        for(int i=0; i<n; i++) {
            scanf("%s",s);
            memset(num1,0,sizeof(num1));
            for(int j=0; j<12; j++)
                num1[s[j]-'A']++;//记录字母出现的次数
            for(int k=0; k<26; k++)
                num[k]=min(num[k],num1[k]);//每次去记录的字符串中每个字母出现的最少的次数
        }
        for(int k=0; k<26; k++)
            for(int j=0; j<num[k]; j++)
                printf("%c",k+'A');
        printf("
");
    }
    return 0;
}
我会一直在
原文地址:https://www.cnblogs.com/zhien-aa/p/5402471.html