| ||||||||||
| 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 "stdio.h"
#define N 500
#define M 5000
main()
{
int m,n,a,b,i,q[N],k;
scanf("%d %d",&n,&m);
while(n!=0||m!=0)
{
for(i=0;i<n;i++)
q[i]=i+1;
k=0;
for(i=0;i<m;i++)
{
scanf("%d %d",&a,&b);
if(q[a]!=0&&q[b]!=0)
{k++;q[a]=0;q[b]=0;}
if(q[a]==0&&q[b]!=0)
q[b]=0;
if(q[a]!=0&&q[b]==0)
q[a]=0;
}
for(i=0;i<n;i++)
if(q[i]!=0)
k++;
printf("%d\n",k);
scanf("%d %d",&n,&m);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator