| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Faint...怎么回事?C++ WA,G++ 0MS..不知道是不是代码哪里出问题咯?#include <iostream> using namespace std; #define maxlen 110 char Finish[maxlen],s1[maxlen],s2[maxlen*2]; int len; void Shuffle(char *tmp,char *tmp1,char *tmp2) { int i,k; for(k=i=0;i<len&&k<2*len;i++) tmp[k++]=tmp2[i],tmp[k++]=tmp1[i]; tmp[2*len]=0; } void Break(char *tmp,char *tmp1,char *tmp2) { int i,k; for(k=0,i=len;i<2*len;k++,i++)tmp2[k]=tmp[i]; tmp2[len]=0; for(i=0;i<len;i++)tmp1[i]=tmp[i]; tmp1[len]=0; } int main() { char tmp[maxlen*2],tmp1[maxlen],tmp2[maxlen]; int n,ncase,answer; scanf("%d",&ncase); for(n=1;n<=ncase;n++) { scanf("%d",&len);scanf("%s%s%s",s1,s2,Finish); strcpy(tmp1,s1);strcpy(tmp2,s2); answer=0; while(true) { Shuffle(tmp,tmp1,tmp2);answer++; if(strcmp(tmp,Finish)==0) { printf("%d %d\n",n,answer); break; } Break(tmp,tmp1,tmp2); if(strcmp(tmp1,s1)==0) { printf("%d -1\n",n); break; } } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator