|
|
back to boardHelp Please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 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:) |
|
|