大佬们,我这样写可以吗,为什么数字进不到数组里面
查看原帖
大佬们,我这样写可以吗,为什么数字进不到数组里面
1494443
wdmzjhyk楼主2024/10/29 10:21
#define _CRT_SECURE_NO_WARNINGS 
#include<stdio.h>
int a[1000];
int main()
{
	int n,c;
	int i = 0;
	scanf("%d", &n);
	for(;n>1; n=(n % 2 == 0) ? (n /= 2) : (n = n * 3 + 1))
	{
		a[i] = n;
		i++;
	}
	for (c = i; c >= 0; c--)
	{
		printf("%d",a[i]);
	}
	return 0;
}
2024/10/29 10:21
加载中...