c/c++问题,简单,高手近

来源:百度知道 编辑:UC知道 时间:2024/05/31 11:42:57
Reverse root
Time Limit: 2.0 second
Memory Limit: 16 MB

The problem is so easy, that the authors were lazy to write a statement for it!
Input

The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.
Output

For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.
Sample
input

output

1427 0

876652098643267843
5276538

2297.0716
936297014.1164
0.0000
37.7757
我写的,到底那里错啦。。。

#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
double ssqrt[4370],n;
int i=0;
while(cin>>n

真惭愧啊! 我看不出这程序哪有溢出
256kB只是限制输入流的, 可能是怕输入太多造成输入缓冲区溢出,想必你也没有耐心在屏幕上敲上256K个字符吧!
从程序上看当i>4370时会越界,一般也不会输入这么多.
至于for(i-=1;i>=0;i--)这更不会有问题啦!因为i-=1只是对i初始化, 只有初始化后i>=0才输出

for(i-=1;i>=0;i--)
这儿应该是
for(;i>=0;i--)
没仔细看程序。。。呵呵

米若明说的对。。for(i-=1;1>=0;1--)这里面有一个小bug。。就是当然1>=0时。。1-=1才成立。。否则1--就变成1++了。。