美文网首页
1059 C语言竞赛 (20 分)

1059 C语言竞赛 (20 分)

作者: 79d12e22ec53 | 来源:发表于2019-07-22 14:08 被阅读0次
    #include<stdio.h>
    
    int isPrime(int x)
    {
        int i;
        for(i=2; i<(x/2)+1; i++)
        {
            if(x%i == 0)
                return 0;
        }
    
        return 1;
    }
    
    
    int main()
    {
        int N;
        int k;
        int search, count[10000]={0};
        int rank = -1;
        int ID[10000];
        int i, j;
    
        scanf("%d", &N);
    
        for(i=0; i<N; i++)
        {
            scanf("%d", &ID[i]);
        }
    
        scanf("%d", &k);
        for(i=0; i<k; i++)
        {
            scanf("%d", &search);
            rank = -1;
            for(j=0; j<N; j++)
            {
                if(search == ID[j])
                {
                    rank = j;
                    count[rank]++;
                }
            }
            if(rank == -1)
            {
                printf("%04d: Are you kidding?\n", search);
            }
            else if(count[rank] > 1)
            {
                printf("%04d: Checked\n", search);
            }
            else
            {
                printf("%04d", search);
    
                if(rank+1 == 1)
                   printf(": Mystery Award\n");
                else if(isPrime(rank+1))
                    printf(": Minion\n");
                else
                    printf(": Chocolate\n");
            }
    
        }
    
    }
    
    

    相关文章

      网友评论

          本文标题:1059 C语言竞赛 (20 分)

          本文链接:https://www.haomeiwen.com/subject/zxxwlctx.html