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 asterix314 at 2007-08-26 21:37:22 on Problem 1005
In Reply To:高手指点 哪里错了? Posted by:harryyang at 2007-08-20 12:05:08
malloc 不对吧,里边应该有个 sizeof(float)。

> #include<stdio.h>
> #include<math.h>
> #include<memory.h>
> #define PI 3.14159265
> void main(){
> 	int totalSets,i,n;float *x,*y,distanceSquare;
> 	fscanf(stdin,"%d",&totalSets);
>          getc(stdin);
> 	x=(float *)malloc(totalSets+1);
> 	y=(float *)malloc(totalSets+1);
> 	for(i=1;i<=totalSets;i++){
> 		fscanf(stdin,"%f %f",&x[i],&y[i]);
>                   getc(stdin);
> 	}
> 	for(i=1;i<=totalSets;i++){
> 		distanceSquare=x[i]*x[i]+y[i]*y[i];
> 		n=ceil(PI*distanceSquare/100);
> 		fprintf(stdout,"Property %d: This property will begin eroding in year %d.\n",i,n);
> 	}
>          fprintf(stdout,"END OF OUTPUT.\n");
> }

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