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

can anyone tell me why WA?(C++)
Posted by QIAO YANG 29 May 2008 19:48
#include <iostream>
#include<vector>
#include<iomanip>
#include <math.h>
using namespace std;
int main()
{
    double a;
    vector<double> vd;

    while(cin>>a)
    {

        vd.push_back(a);
    }

    cout.setf(cout.showpoint);
    setprecision(4);
    setiosflags(ios::fixed);

    for(vector<double>::size_type i=vd.size()-1;i!=-1;--i)
    {

        cout<<pow(vd[i],0.5)<<endl;
    }

    return 0;
}
Re: can anyone tell me why WA?(C++)
Posted by Howard Liu 30 May 2008 03:41
setprecision and setiosflags didn't have any effect in your code. You need to put them in some 'cout << ' line.
Re: can anyone tell me why WA?(C++)
Posted by rainerzhou 23 Jul 2008 13:22
Try to change these lines
cout.setf(cout.showpoint);
setprecision(4);
setiosflags(ios::fixed);
to
cout.setf(ios::fixed);
cout.precision(4);