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 dgz19900901 at 2012-03-13 11:02:38 on Problem 1005 and last updated at 2012-03-13 11:02:58
#include <iostream>
#include <cmath>
using namespace std;

#define PI 3.141593

int main()
{
	int n;//how many sets
	float* x;
	float* y;
	float* radius;
	int i;//year
	int j=0;
	int count=0;
	int *result;//存放结果,为了最终按顺序打印
	float r;//每年淹没的半径
	cin>>n;
	x = (float*)malloc(sizeof(float)*n);
	y = (float*)malloc(sizeof(float)*n);//数目不确定,只能用指针
	radius = (float*)malloc(sizeof(float)*n);

	result = (int*)malloc(sizeof(int)*n);

	for(i=0;i<n;i++)//有多少n就要有多少对xy
	{
		cin>>*(x+i)>>*(y+i);
		*(radius+i) = sqrt((*(x+i))*(*(x+i)) + (*(y+i))*(*(y+i)));
		*(result+i)=0;
	}

	for(i=1;;i++)//按年份往上算
	{
		r = sqrt(50.0*2*i/PI);
		for(j=0;j<n;j++)
		{
			if(*(radius+j)<=r && *(result+j)==0)//第j组被淹				
			{				
				*(result+j) = i;
				count++;
			}
		}				
		if(count==n)
			break;
	}

	for (i=0;i<n;i++)
		cout<<"Property "<<i<<": This property will begin eroding in year "<<*(result+i)<<"."<<endl;
	cout<<"END OF OUTPUT.";

	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