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 guangdianytm at 2015-03-17 12:57:54 on Problem 1939
用C编怎么判断结束?
if(EOF==scanf(%d,&pairs))
break;
貌似不行啊
#include<stdio.h>
int main()
{    
	 double xpos[1000],ypos[1000]; 
	 int i; 
	 int pairs;
      while(1)
	  {
		  scanf("%d",&pairs);
		  if(EOF==pairs)
		      break;
	      for(i=0;i<pairs;i++)
		  {
		        scanf("%lf",&xpos[i]);
		        scanf("%lf",&ypos[i]);
		  }
	      printf("%d ",pairs);
		  for(i=0;i<pairs-1;i++)
			  printf("%.6f %.6f ",(xpos[i]+xpos[i+1])/2,(ypos[i]+ypos[i+1])/2);
		    printf("%.6f %.6f\n",(xpos[i]+xpos[0])/2,(ypos[i]+ypos[0])/2);
	  }
}

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