2018年1月13日 星期六

UVA Q340 - Master-Mind Hints

#include<iostream>
using namespace std;
int main(){
int a,c[1000],d[1000],h[1000],e,f,g=1;
bool aa;
while(cin>>a){
    if(a==0){
        break;
    }
        for(int x=0;x<a;x++){
            cin>>c[x];
        }
    cout<<"Game "<<g<<":"<<endl;
    while(1){
        e=0;
        f=0;
        aa=1;
        for(int x=0;x<a;x++){
            cin>>d[x];
            if(d[x]!=0){
                aa=0;
            }
        }
        if(aa==1){
            break;
        }
        for(int x=0;x<a;x++){
            h[x]=c[x];
        }
        for(int x=0;x<a;x++){
            if(h[x]==d[x]){
                e++;
                h[x]=-2;
                d[x]=-1;
            }
        }
        for(int y=0;y<a;y++){
            for(int x=0;x<a;x++){
                    if(h[y]==d[x]){
                        h[y]=0;
                        d[x]=-3;
                        f++;
                    }
                }
        }
       
        cout<<"    ("<<e<<","<<f<<")"<<endl;
    } g++;
}


system("pause");
return 0;
}

沒有留言:

張貼留言