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:实在不知道哪错了

Posted by isittrue at 2005-08-09 17:39:22 on Problem 2395
In Reply To:实在不知道哪错了 Posted by:isittrue at 2005-08-09 17:33:15
> #include <iostream.h>
> #include<stdlib.h>
> #define LEN sizeof(struct line)
> 
> struct line{
> 	int x,y;
> 	double l;
> 	struct line *next;
> }*head;
> 
> void insert(int start,int end,double length){
> 	struct line *p,*q,*w;
> 	p=(struct line *)malloc(LEN);
> 	p->next=NULL;
> 	p->x=start; p->y=end;
> 	p->l=length;
> 	q=head->next; w=head;
> 	while((q!=NULL)&&(q->l<p->l)) {
> 		w=q; q=q->next;
> 	}
> 	w->next=p; p->next=q;
> }
> 
> void main(){
> 	struct line *p;
> 	int s[2001];
> 	int i,n,m,k,start,end;
> 	double max,length;
> 
> 	cin>>n>>m; 
> 
> 	head=(struct line *)malloc(LEN); head->next=NULL; head->l=0;
> 
> 	for(i=0;i<2001;i++) s[i]=1; s[1]=0;
> 	while(m--){
> 		cin>>start>>end>>length;
> 		insert(start,end,length);
> 	}
> 
> 	p=head->next; max=0;
> 	while(p!=NULL){
> 		if((s[p->x]==0)&&(s[p->y]==0)) { p=p->next; continue; }
> 
> 		s[p->x]=0; s[p->y]=0; 
> 
> 		if(p->l>max) max=p->l;
> 
> 		p=p->next;
> 	}
> 
> 	cout<<"\n"<<max<<"\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