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 challenging at 2006-02-28 15:33:07 on Problem 1003
#include<iostream>
#include<string>
#include <iomanip>
using namespace std ;
struct temp
{
	float tmp ;
	temp* next ;
	temp()
	{tmp=0.00;
	 next = NULL ;
	}
};
typedef temp * Tmp ;
float add(int n) ;
void find(Tmp m) ;
Tmp q ;
int main()
{
	int i=1;	
	float h ;
	cin>> h ;
	Tmp p ,n;
	p = new temp ;
	while(h!=0.00)
	{
		n = new temp ;
		n->tmp = h ;
		if(q==NULL)
		{   
			q = n ;p = n ;
		}
		else
		{ p->next = n ;
		  p = n ;
		}
		cin>> h ;
	}

	find(q);
}
float add (int n)
{
	if(n ==1)
		return 0.5 ;
	else
		return add(n-1) +(float)1.0/(n+1) ;
}
void find(Tmp m) 
{
	Tmp  p ;
	 p = m;
	 int j = 1 ;
	 while(p!= NULL)
	 {
		 if(p->tmp>=0.01 && p->tmp<=5.20)
		 { 
            if( p->tmp <= 0.5)
				 cout<<"1 card(s)"<<endl ;
			else
			{
				while( p->tmp > add(j))
		        j++ ; 		 
			
				 if( p->tmp ==add(j-1))
				     cout<< j-1<<" card(s)"<<endl  ;
				 else
					 if( p->tmp >add(j-1)&& p->tmp<=add(j))
						 cout<<j<<" cars(s)"<<endl ;
			}
		 p =p->next ;
	 }
}

}

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