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

1207

Posted by 1363217105 at 2011-06-14 22:42:16 on Problem 1207
为什么输不出结果啊,帮忙看一下代码
#include<iostream>
using namespace std;
#include<algorithm>
int cmp(int a,int b)
{
return a<b;
}
int main()
{
	int i,j,n,k,m,s[10000];
	while(cin>>i>>j)
	{   
		k=0;
		for(n=i;n<j;n++)
		{  s[k]=1;
          while(n!=1)
		  {
             if(n%2==0)
				 n=n/2;
			 else n=3*n+1;
			 s[k]++;
		  }  k++;
	
		}for(m=0;m<k;k++)
             sort(s,s+k,cmp);
		cout<<i<<" "<<j<<" "<<s[k]<<endl;
	}
	return 0;
}

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