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

I don't know what is wrong with my code, could I use stack here?
Posted by JK Love 23 Jan 2022 03:46
#include <iostream>
#include <stack>
#include <cmath>
using namespace std;

int main()
{
    stack<double> root;
    double input;

    while(cin >> input)
    {
        root.push(sqrt(input));
    }

    while(!root.empty())
    {
        cout << root.top() << endl;
        root.pop();
    }

    return 0;
}
Re: I don't know what is wrong with my code, could I use stack here?
Posted by Bilal.Coder 16 Feb 2024 11:59
Here your first input while is going infinnity. You have to stop it.