| ||||||||||
| 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 | |||||||||
Re:大家看看为什么这样不行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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator