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 |
一个典型的初级错误In Reply To:高手帮我看一下我哪里错了呢 Posted by:bike at 2009-07-15 17:27:41 > #include <stdio.h> > int main(int argc, char *argv[]) > { > int m,n,a,count=0,max,k,l,t; > while(scanf("%d%d",&m,&n)!=EOF) > { > k=m; > l=n; > max=0; > if(m>n) > { > t=m; > m=n; > n=t; > } > > for(a=m;a<n;a++) > { > while(a!=1) > { > if(a%2==0) > { > a=a/2; > count++; > } > else > { > a=3*a+1; > count++; > } > } !!!!!!!!!!!!!!!!!!!!!你已经改变了a的值!!!! > if(count>max) > max=count; > > } > printf("%d %d %d",k,l,max); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator