Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

救命啊!!!!错在哪啊?眼都花了

Posted by Csea at 2006-03-14 00:05:24
题1003
#include <iostream>
#include <vector>
using namespace std;
int separate(float c)
{
    if (c <= 1.00)
      return 1;
    
    float j;
    int count = 0; 
    
    j = 2;
    while(c>0)
    {
       c -= float(1/j);
       count++;
       j++;
    }
    
    return count;
}
int main()
{
    float c;
    vector<float> fVec;
    cin >> c;
    while (c!=0.00)
    {
          fVec.push_back(separate(c));
          cin >> c;
    }
    for (int i = 0; i < fVec.size(); i++)
      cout << fVec[i] << " card(s)" << endl;
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator