两个有错误的代码,先存着。大神帮忙看看

/*#include
#include
#include
using namespace std;
int re[50];
int address[1050];
int main()
{
int i,n;
int k,m;
bool chc=true;
char s[1050];
gets(s);
sscanf(s,"%d",&n);
gets(s);
while(n--)
{
memset(re,0,sizeof(re));
memset(address,0,sizeof(address));
k=0;
m=0;
while(gets(s))
{
if(s[0]=='\0')
break;
int temp=0;
sscanf(s,"%d",&temp);
address[k++]=temp;
}
i=0;
while(true)
{
int code=address[i++];
int a=code/100;
int b=(code/10)%10;
int c=code%10;
m++;
if(code==100)
{
break;
}
switch(a)
{
case 2:re[b]=c%1000;
break;
case 3: re[b]=(re[b]+c)%1000;
m++;
break;
case 4:re[b]=(re[b]*c)%1000;
break;
case 5:re[b]=re[c]%1000;
break;
case 6: re[b]=(re[b]+re[c])%1000;
break;
case 7: re[b]=(re[b]*re[c])%1000;
break;
case 8: re[b]=address[re[c]]%1000;
break;
case 9:  address[re[c]]=re[b]%1000;
break;
case 0: if(re[c])
{
i=(re[b])%1000;
}
break;
}
}
if(chc)   
chc=false;
else
cout< cout< }
return 0;
}*/
#include
#include
#include
#include   
#include  
using namespace std;
bool dealgood(string b,string* a,int sum,bool link[][300])
{
int i,j,num=0,f;
bool lk[300][300];
for(i=0;i<=sum;i++)
for(j=0;j<=sum;j++)
lk[i][j]=link[i][j];
for(i=0;i {
for(j=i+1;j {
if(lk[i+1][j+1]==true&&(b==a[i]+a[j]||b==a[j]+a[i]))
{
//lk[i+1][j+1]=false;
for(f=j+1;f num++;
break;
}
}
}
if(num==sum/2)
return true;
else
return false;
}
int main()
{
int n;
cin>>n;
getchar();
getchar();
string a[300];
string b[2];
int i=0,j,sum;
bool ok1,ok2;
int sum0=0;
int sum1=0;
int ss[300];
memset(ss,0,sizeof(ss));
int dd[300];
memset(dd,0,sizeof(dd));
bool link[300][300];
memset(link,0,sizeof(link));
while(n>0&&getline(cin,a[i++]))
{
if(a[i-1].length()!=0)
{
for(j=0;j   {
if(a[i-1][j]=='0')
{sum0++;ss[i-1]++;}
else if(a[i-1][j]=='1')
{sum1++;dd[i-1]++;}
  }
}
else
{
sum=i-1;
sum0/=(sum/2);
sum1/=(sum/2);
for(i=0;i for(j=i+1;j if(ss[i]+ss[j]==sum0&&dd[i]+dd[j]==sum1)
link[i+1][j+1]=true;
for(j=1;j {
if(link[1][j+1]==true)
{
b[0]=a[0]+a[j];
b[1]=a[j]+a[0];
ok1=dealgood(b[0],a,sum,link);
ok2=dealgood(b[1],a,sum,link);
if(ok1||ok2)
{i=sum;break;}
}
}
if(ok1)
cout< else
cout< n--;
if(n)
{
memset(a,0,sizeof(a));
memset(ss,0,sizeof(ss));
memset(dd,0,sizeof(dd));
memset(link,0,sizeof(link));
i=0;
sum0=0;
sum1=0;
cout< }
}
}
return 0;
}

你可能感兴趣的:(两个有错误的代码,先存着。大神帮忙看看)