| ||||||||||
| 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 | |||||||||
求教,总是过不了,但是自己感觉是没问题#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator