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

Re:runtime error 怎么解决

Posted by 1290577924 at 2011-11-23 21:30:29 on Problem 1094
In Reply To:runtime error 怎么解决 Posted by:200830690100 at 2010-03-09 13:57:31
> #include<stdio.h>
> 
> int s[26][26];
> int m, n;
> char ch[26];
> 
> int top_sort(){
> 	int i,j,k,c,g=0,t[26];
> 	char o;
> 	for(i=0;i<n;i++)t[i]=0;
> 	for(k=0;k<n;k++){
> 		c=0;
> 		for(i=0;i<n;i++)if(t[i]==0){
> 			for(j=0;j<n;j++)if(t[j]==0&&s[j][i]==1)break;
> 			if(j==n){o=char('A'+i);c++;}
> 		}
> 		t[o-'A']=1;
> 		if(c==0)return 1;
> 		if(c==1){ch[g++]=o;if(g==n)return 2;}
> 		if(c>1)break;
> 	}
> 	for(i=0;i<n;i++)t[i]=0;
> 	for(k=0;k<n;k++){
> 		c=0;
> 		for(i=0;i<n;i++)if(t[i]==0){
> 			for(j=0;j<n;j++)if(t[j]==0&&s[j][i]==1)break;
> 			if(j==n){o=char('A'+i);c++;}
> 		}
> 		t[o-'A']=1;
> 		if(c==0)return 1;
> 	}
> 	return 0;
> }
> 
> 
> void Sort(){
> 	int i,j,k;
> 	char str[1000][3];
> 	for(i=0;i<n;i++)
> 		for(j=0;j<n;j++)s[i][j]=0;
> 	for(k=0;k<m;k++){
> 		scanf("%s",str[k]);
> 		s[str[k][0]-'A'][str[k][2]-'A']=1;	
> 		j=top_sort();
> 		if(j!=0){i=k+1;goto loop;}
> 	}
> loop:for(k++;k<m;k++)scanf("%s");
> 	if(j==0)printf("Sorted sequence cannot be determined.\n");
> 	if(j==1)printf("Inconsistency found after %d relations.\n",i);
> 	if(j==2) {
> 		printf("Sorted sequence determined after %d relations: ",i);
> 		for(i=0;i<n;i++)printf("%c",ch[i]);
> 		printf(".\n");
> 	}
> }
> 
> int main(){
> 	scanf("%d",&n);
> 	scanf("%d",&m);
> 	while(m*n!=0){
> 		Sort();
> 		scanf("%d",&n);
> 		scanf("%d",&m);
> 	}
> 	return 1;
> }

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