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

c++新手,程序特别乱,而且无法运行,求大神帮忙看看

Posted by shuliu2 at 2012-11-21 11:36:16 on Problem 1003
#include <iostream>
#include <string>
#include "stdio.h"
///#include "stdafx.h"

using namespace std;

#define ZERO 1e-100
#define MIN 0.01
#define MAX 5.20

int test(int i)
{
	double len;
	double c;
	cout<<"input the length c: ";
	cin>>c;
	cout<<endl;

	if(sizeof(c)>4 || c>MAX || c<MIN)
		cout<<"invalid input!"<<endl;
	else
	{
		for(int i=1;;)
		{
			len += 1/float(i+1);
			if(abs(len - c) <= ZERO)
				return i;
			else
				i++;
		}
	}
}

int main()
{
	double c;
	int n,i;
	n = test(i);
	cout<<"at least "<<n<<" cards are needed."<<endl;
}

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