Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
实在不知道哪错了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator