Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮帮忙!为什么总是Wrong Answer错误! 谢谢!

Posted by X_CrDjN at 2006-07-20 09:26:01 on Problem 2260
# include <stdio.h>
# include <malloc.h>
main()
{ int xx[101][101],a[101],b[101],i,n,j,x=0,y=0;
typedef struct node{ int x,y,flag;struct node *link;} JD; JD *h,*r,*v;
h=(JD *)malloc(sizeof(JD));h->link=NULL;r=h;for (i=0;i<=100;i++) {a[i]=0;b[i]=0;}
scanf("%d",&n);
while (n!=0 && n<100)
{for (i=1;i<=n;i++)
{	for (j=1;j<=n;j++){scanf("%d",&xx[i][j]);if (xx[i][j]!=0 ||xx[i][j] !=1) return(0);a[i]+=xx[i][j];b[j]+=xx[i][j];}
}
for (i=1;i<=n;i++)
{v=(JD *)malloc(sizeof(JD));
for (i=1;i<=n;i++){if ((a[i]%2)!=0) x=x+1;if ((b[i]%2)!=0) y=y+1;}
if (x==1&&y==1) {v->flag=1;for (i=1;i<=n;i++) {if ((a[i]%2!=0)) {v->x=i;}if ((b[i]%2!=0)) {v->y=i;} }v->link=NULL;h->link=v;h=h->link;}
else if(x==0 && y==0) {v->flag=0;
v->link=NULL;h->link=v;h=h->link;}
else {v->flag=-1;
v->link=NULL;h->link=v;h=h->link;}
}scanf("%d",&n);x=0;y=0;
for (j=1;j<=n;j++){a[i]=0;b[j]=0;}
}
r=r->link;
for(;r->link!=NULL;){if (r->flag==0) printf("OK\n");if (r->flag==1) printf("Change bit (%d,%d)\n",r->x,r->y);if (r->flag==-1) printf("Corrupt\n");r=r->link;}
if (r->flag==0) printf("OK\n");if (r->flag==1) printf("Change bit (%d,%d)\n",r->x,r->y);if (r->flag==-1) printf("Corrupt\n");
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator