Uva 10474 - Where is the Marble?

水个题吧

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
    int i,j,k,m,n,cishu=1,r,s,t,N,Q;
    int marble[10000]={0},question[10000]={0};
    while( scanf("%d %d",&N,&Q) != EOF )
    {
        if(N == 0 && Q == 0)
            break;
        for(i=0; i<N; i++)
            scanf("%d",&marble[i]);
        for(i=0; i<Q; i++)
            scanf("%d",&question[i]);
        for(i=1; i<=N-1; i++)
            for(j=0; j<N-i; j++)
                if(marble[j] > marble[j+1])
                {
                    t=marble[j];
                    marble[j]=marble[j+1];
                    marble[j+1]=t;
                }
        printf("CASE# %d:\n",cishu);  cishu++;
        for(i=0; i<Q; i++)
        {
            t=0;
            for(j=0; j<N; j++)
                if(question[i] == marble[j])
                {  t=1;    break; }
            if(t == 1)
                printf("%d found at %d\n",question[i],j+1);
            else
                printf("%d not found\n",question[i]);
        }
    }
    return 0;
}


你可能感兴趣的:(Uva 10474 - Where is the Marble?)