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.h> #include<math.h> long f(long num) { long i=0,result; while(1) { i++; result=i*(i+1)/2; if(result>=num) break; } i--; return i; } void main() { long num,a,b,data; while(cin) { cin>>num; data=f(num); if(data%2==0){ a=num-data*(data+1)/2; b=data+2-a; } else {b=num-data*(data+1)/2; a=data+2-b;} cout<<"TERM "<<num<<" IS "<<b<<"/"<<a<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator