CF Gym 100637G \#TheDress (水)

题解:读懂题意按照题意模拟。。。

熟悉了一个库函数,strstr,memcpy

#include<cstdio>

#include<cstring>



int main()

{

    int N;

    char str[150];

    int cnt[3] = {0};

    scanf("%d",&N); getchar();

    for(int j = 0; j < N; j++){

        gets(str);

        if(strstr(str,"black")&&strstr(str,"blue")) cnt[0]++;

        else if(strstr(str,"white")&&strstr(str,"gold")) cnt[1]++;

        else cnt[2]++;

    }

    double sum = cnt[0] + cnt[1] + cnt[2];

    printf("%.10lf\n%.10lf\n%.10lf",cnt[0]/sum*100,cnt[1]/sum*100,cnt[2]/sum*100);

    return 0;

}

 

你可能感兴趣的:(res)