验证角谷猜想 c语言#include int main (){int n;while(1==scanf("%d",&n)){int a ;while(n--&&(1==scanf("%d",&a))){int count=0;for (;a!=1;){if (a%2==1){printf("%d ",a);count++;}if (a%2==1)a=a*3+1;else a =a/2;}if (count!=0)printf("\n");if (count==0)
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 08:25:32
验证角谷猜想 c语言#include int main (){int n;while(1==scanf("%d",&n)){int a ;while(n--&&(1==scanf("%d",&a))){int count=0;for (;a!=1;){if (a%2==1){printf("%d ",a);count++;}if (a%2==1)a=a*3+1;else a =a/2;}if (count!=0)printf("\n");if (count==0)
验证角谷猜想 c语言
#include
int main ()
{
int n;
while(1==scanf("%d",&n))
{
int a ;
while(n--&&(1==scanf("%d",&a)))
{
int count=0;
for (;a!=1;)
{
if (a%2==1)
{
printf("%d ",a);
count++;
}
if (a%2==1)
a=a*3+1;
else
a =a/2;
}
if (count!=0)
printf("\n");
if (count==0)
printf("No number can be output!\n");
}
return 0;
}
}
怎样去掉最后一个输出后面的空格?
验证角谷猜想 c语言#include int main (){int n;while(1==scanf("%d",&n)){int a ;while(n--&&(1==scanf("%d",&a))){int count=0;for (;a!=1;){if (a%2==1){printf("%d ",a);count++;}if (a%2==1)a=a*3+1;else a =a/2;}if (count!=0)printf("\n");if (count==0)
if (count!=0)
printf("\b\n");加个\b退位