ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

Difference in compilers?
Posted by Ade 29 May 2013 22:09

The question is simple. So is my code. See below It gets AC in VC++2000.
But why does it get WA#1 in gcc4.7.2 and gcc4.7.2-c++11, until I replace the while-scanf loop with the commented while-cin loop?

Thanks.

--

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
int main()
{
    std::vector<long long> v;
    long long t;
    while (std::scanf("%lld", &t) != EOF) {
    // while (std::cin >> t) {
        v.push_back(t);
    }
    for (int i=v.size()-1; i>=0; --i) {
        printf("%.5f\n", sqrt((double)(v[i])));
    }
}