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

why first AC and second NOT?
Posted by NotLazy 15 Oct 2007 12:11
first is:

int main()
{
    using namespace std;

    vector<unsigned long long> dataVec;

    unsigned long long input;
    while (cin>>input)
    {
        dataVec.push_back(input);
    }

    vector<unsigned long long>::reverse_iterator rIter;

    cout.setf(ios_base::fixed);
    cout.setf(ios_base::showpoint);
    for (rIter = dataVec.rbegin(); rIter != dataVec.rend(); ++rIter)
    {
        cout<<setprecision(4) <<sqrt((double)(*rIter))<<endl;
    }

    return 0;
}




second is :


int main()
{
    using namespace std;

    vector<unsigned long long> dataVec;
    string lineStr;
    while(!getline(cin, lineStr).eof())
    {
        unsigned long long tmp = 0;
        stringstream ss(lineStr);
        while(ss>>tmp)
            dataVec.push_back(tmp);

    }

    vector<unsigned long long>::reverse_iterator rIter;

    cout.setf(ios_base::fixed);
    cout.setf(ios_base::showpoint);
    for (rIter = dataVec.rbegin(); rIter != dataVec.rend(); ++rIter)
    {
        cout<<setprecision(4) <<sqrt((double)(*rIter))<<endl;
    }

    return 0;
}