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

真心不会了,到底应该怎样结束输入,为什么我怎么改都是wa

Posted by Codievilky at 2012-08-11 19:03:11 on Problem 1207
求指点,求改正啊
#include<iostream>
int algrithm(int n){
	int count=1;
	while(n!=1){
		if(n%2==0)
			n=n/2;
		else 
			n=3*n+1;
		count++;
	}
	return count;
}
int main(){
	int i,j;
	while(scanf("%d%d",&i,&j)!=EOF){
	if(j<i){
		int temp=i;
		i=j;
		j=temp;
	}
	int max=0;
	for(int kk=i;kk<=j;kk++){
		int anwser=algrithm(kk);
		if(max<anwser)
			max=anwser;
	}
	printf("%d %d %d\n",i,j,max);
	}
	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