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

Help Please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Posted by Julius Canute 21 Jan 2007 21:50
This Pgm is producing correct output but solution is not accepted????????????????????????????????????????????
#include <iostream>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <stdlib.h>
using namespace std;
double return_double(string ch)
{
istringstream istr(ch);
double i;
istr >> i;
return sqrt((double)i);
}
string word(string line3,int &len)
{
string temp;
while((len>0)&&(!isalnum(line3[len])))len--;
while((len>0)&&(isalnum(line3[len])))
temp = line3[len--] + temp;
return temp;
}
int main()
{    string line1,line2,temp;

     int i,num=0;
     int len=0;

while (getline(cin,line1))
{
  line2 =  line2+' '+line1;
}
len=line2.length();

while(len>0)
{
    temp = word(line2, len);
    cout<<setprecision(4)<<fixed<<return_double(temp)<<endl;

}


return 0;
}
Re: Help Please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Posted by Vindhyeshwari Kashyap 26 Jan 2007 21:35
have u considered if last charectors are saved or not...

say
55 0 11<newline>
44 444<newline>
4454<end of file 'Ctrl-Z' without newline>

in this scenario last chars are not captured by your program... probably:)