|
|
вернуться в форумCompilation Error Послано SPAV 8 апр 2011 19:19 Where is the mistake? Without 'sqrt' program compiled on server. On my computer all works. Why? #include <iostream> #include <stack> #include <cmath> using namespace std; int main() { long long a; stack<long long> s;
while(cin>>a) s.push(a);
while(!s.empty()) { cout<<sqrt(s.top())<<endl; s.pop(); }
}
Edited by author 08.04.2011 19:21 Re: Compilation Error Послано Ahmad 16 апр 2011 17:23 You should use <iomanip> libary and use its function. your code is good and I learn new thing from it. you should rewrite this line of code( cout<<sqrt(s.top())<<endl;) TO cout<<fixed<<setprecision (4)<<sqrt(s.top())<<endl; Regards, Re: Compilation Error Compilation Error occured because yout main fuction must return an integer value ( 0 ). also sqrt function argument can not be long long. change it to long double. and use: cout <<setiosflags( ios::fixed | ios::showpoint ) << setprecision(4) << sqrt( s.top() ) << endl; |
|
|