This is the link to the question on UVA judge
http://ift.tt/1HkUBfl
My Code is
using namespace std;
void init(string * original,string *dup){
int count=1;
string value[13]={"2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"};
string suit[4]={"Clubs","Diamonds","Hearts","Spades"};
for(int i=0;i<4;i++){
for(int j=0;j<13;j++){
original[count]=value[j]+" of "+suit[i] ;
dup[count]=value[j]+" of "+suit[i];
count++;
}
}
}
void shuffles(int shuffle[][53],int n ){
for(int i=1;i<=n;i++){
for(int j=1;j<=52;j++){
cin>>shuffle[i][j];
}
}
}
void positionofcards(string *from,string *to,int n,int shuffle[][53]){
for(int i=1;i<=52;i++){
to[i]=from[shuffle[n][i]];
}
}
void printing(string * s){
for(int i=1;i<=52;i++){
cout<<s[i]<<endl;
}
}
int main() {
int testcases;
string original[53];
string dup[53];
int shuffle[101][53];
int n;
int count;
cin>>testcases;
scanf("\n");
while(testcases-->0){
cin>>n;
count=0;
init(original,dup);
shuffles(shuffle,n);
char input[5];
scanf("\n");
while(fgets(input,5,stdin)!=NULL){
if(input[0]=='\n')
break;
if(count%2==0)
positionofcards(original,dup,atoi(input),shuffle);
else
positionofcards(dup,original,atoi(input),shuffle);
count++;
}
if(count%2==0){
printing(original);
}
else
printing(dup);
cout<<endl;
}
return 0;
}
I get wrong answer on the judge.What is the mistake.
Aucun commentaire:
Enregistrer un commentaire