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

你的程序越界了吧

Posted by zhb_msqx at 2007-09-12 12:06:55 on Problem 2864
In Reply To:高手帮忙指点一下哈!真不知错哪里了 Posted by:VCSun at 2007-07-25 02:50:23
#include <stdio.h>
main()
{
	int a[200][100];
	int N;
	int D;
	int i,j;
	int flag;
	while(scanf("%d %d",&N,&D)!=EOF&&N!=0&&D!=0)
	{
		for(i=0;i<50;i++)
		for(j=0;j<10;j++)
		a[i][j]=1;
		for(i=1;i<=D;i++)
			for(j=1;j<=N;j++)
			scanf("%d",&a[i][j]);

		for(i=1;i<=N;i++)
		{
			flag=1;
			for(j=1;j<=D;j++)
		{
			flag=a[j][i]*a[j-1][i]; 
                  j一共只有D组,如果从1开始访问,那么a[j-1][i]就越界了!
			if(flag==0)break;
			else if(j==D&&flag==1)goto L;
		}
		}
		L:
		if(flag)printf("yes\n");
		else printf("no\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