Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 贴个代码,并提示一下可能错的一个地方

Posted by a280920481 at 2018-11-08 18:59:07 on Problem 3684
```#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
int C, N, H, R, T, ians[4];//案例数 球数 高度 半径 时间 整数结果
double et, rt, ans[105];//一次下落或上升的时间 剩余时间 浮点结果

cin >> C;

for (int so = 0; so < C; so++)
{
cin >> N >> H >> R >> T;

et = sqrt(H / 5.0);

for (int i = 0; i < N; i++)
{
if (T > i)
{
rt = T - i - ((int)((T - i) / et))*et;
if (((int)((T - i) / et)) % 2)//上升阶段
{
ans[i] = H - 5 * (et - rt)*(et - rt);
}
else//下降阶段
{
ans[i] = H - 5 * rt*rt;
}
}
else
{
ans[i] = H;
}
}

sort(ans, ans + N);//先排序,再加各自的次序乘直径

for (int i = 0; i < N; i++)
{
ians[0] = (int)((ans[i] + i * R / 50.0) * 100 + 0.5);//四舍五入保留小数点后2位
ians[1] = ians[0] / 100;
ians[2] = (ians[0] % 100) / 10;
ians[3] = ians[0] % 10;

if (i)
{
cout << ' ';
}
cout << ians[1] << '.' << ians[2] << ians[3];
}

cout << '\n';
}

return 0;
}

```

Followed by: