c++ - What is wrong with this solution of mine for the PKU Judge ID 1003? -


here link problem id 1003 of pku judge: http://poj.org/problem?id=1003

all need problem calculate sum of harmonic progression , compare variable have inputted

i getting right answers sample input cases, don't know why answer not getting accepted? getting 'wrong answer' result. part in problem says "the input consists of 1 or more test cases, followed line containing number 0.00 signals end of input" don't know how 0.00 part, taking single input, didn't understand how that?

here solution:

#include<iostream>  using namespace std;  int main() {      float c;     float sum = 0;     cin >> c;      short int = 1;      while(1)     {         sum += (float)1/(i+1);          if(sum >= c)         {             cout << << " card(s)";             break;         }         i++;     }     return 0; } 

the input consists of 1 or more test cases, followed line containing number 0.00 signals end of input. each test case single line containing positive floating-point number c value @ least 0.01 , @ 5.20; c contain 3 digits.

your program won't take correct input.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -