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 |
各位高手帮忙啊?看看我的程序错在哪里啊 ?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator