在dev c++上输入任何数都没有输出
在提交评测时输入99
输出1 2 4 8 16 5 10 20 40 13 26 52 17 34 11 22 7 14 28 56 112 224 448 149 298 99
对比了大佬写的题解也感觉没什么问题
请各位大佬斧正
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,k,a[1000];
cin >> n ;
for(i = 0 ; n != 1;i++)
{
a[i] = n;
if(n%2 != 0)
{
n = n * 3 + 1;
}
else
{
n = n / 2;
}
k++;
}
for( i=k ;i>0;i--)
{
cout << a[i] ;
cout << " " ;
}
return 0;
}