标签:pre div col bsp until ati 输入一个正整数n else n+1
//2017-01:角谷猜想 //奇数3*N+1;偶数N/2 ;until N=1 #include <stdio.h> static int count=0; int jiaogu(int num){ if(num==1||num==0){ return 0; }else if(num%2==0){ count++; jiaogu(num/2); }else{ count++; jiaogu(3*num+1); } } int main(){ int inputNum; printf("请输入一个正整数N\n"); scanf("%d",&inputNum); jiaogu(inputNum); printf("需要进行%d次",count); return 0; } //注意了:printf没有&,函数要放在main之前写出来
标签:pre div col bsp until ati 输入一个正整数n else n+1
原文地址:https://www.cnblogs.com/liberhome/p/10515018.html