- #include<stdio.h>
- #include<stdlib.h>
- int aa=0;
- int main(){
- int a,b,i,m,n;
- int hold,stay;
- int ans[100000]={0};
- int check(int,int);
- /*scanf("%d%d",&a,&b);
- printf("%d %d",a,b);
- if(a<b){
- hold=a;
- a=b;
- b=hold;
- }
- for(i=0;b<=a;b++,i++){
- ans[i]=check(b,0);
- printf("%d\n",check(b,0));
- }
- for(m=0;m<=(a-b);m++){
- for(n=0;n<=(a-b);n++){
- if(ans[n]<ans[n+1]){
- stay=ans[n];
- ans[n+1]=ans[n];
- ans[n]=stay;
- }
- }
- }
- printf("%d",ans[0]);*/
- printf("%d %d",check(22,0),aa);
- system("pause");
- return 0;
- }
- int check(int num,int total){
- aa=aa+1;
- printf("%d %d\n",num,total);
- if(num==1)
- return total+1;
- else{
- if(num%2>0)
- check(num*3+1,total+1);
- if(num%2==0)
- check(num/2,total+1);
- }
- }
Raw Paste