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 tiger_2702 at 2004-11-01 19:31:25 on Problem 1969
#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:
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