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 adba at 2007-06-21 23:34:31 on Problem 1005
In Reply To:大家看看为什么这样不行 Posted by:goal00002222 at 2005-11-29 21:15:49
year[i] = (int)(area/n)+1;
这句不对,如果area/n正好没有小数位时,就错了

> #include<stdio.h>
> #include<stdlib.h>
> 
> #define n 100.0
> #define PI 3.14159265
> 
> int main(void)
> {
>    int i, N, *year;
>    double x, y, r2, area;
>     
>     do{
>    	scanf("%d", &N);
>    	fflush(stdin);
> 	} while(N<=0);
>    year = (int *)malloc(N*sizeof(int));
>    if(!year)
>    {
> 		puts("error");
> 		return 1;
> 	}
>    for(i=0; i<N; i++)
>    {
> 		do{
> 			scanf("%lf%lf", &x, &y);
> 			fflush(stdin);
> 		} while(x<0. || y<0. || x==0. && y==0.);
> 		r2 = x*x + y*y;
> 		area = PI*r2;
> 		year[i] = (int)(area/n)+1;	
> 	}
> 	for(i=0; i<N; i++)
> 		printf("Property %d: This property will begin eroding in year %d.\n", i+1, year[i]);
> 	puts("END OF OUTPUT.");
>    system("pause");
>    return 0;   	
> }   

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