Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
c++新手,程序特别乱,而且无法运行,求大神帮忙看看#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator