2个回答
展开全部
根据题目要求,我给你写了一个完整的程序给你参考。
源代码如下(vc++ 6.0下编译通过):
#include <stdio.h>
#define MAX_NUM 4
int main(void)
{
int i = 0;
int num = 0;
int num_count = 0;
int a[MAX_NUM] = { 0 };
printf("please input a number(0-9999): \n");
scanf("%d", &num);
while (num % 10)
{
a[num_count++] = num % 10;
num /= 10;
}
printf("num_count: %d\n", num_count);
printf("sequence: \n");
for (i = num_count - 1; i >= 0; i--)
{
printf("%d ", a[i]);
}
printf("\n");
printf("inverted sequence: \n");
for (i = 0; i < num_count; i++)
{
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
希望对你有帮助。
源代码如下(vc++ 6.0下编译通过):
#include <stdio.h>
#define MAX_NUM 4
int main(void)
{
int i = 0;
int num = 0;
int num_count = 0;
int a[MAX_NUM] = { 0 };
printf("please input a number(0-9999): \n");
scanf("%d", &num);
while (num % 10)
{
a[num_count++] = num % 10;
num /= 10;
}
printf("num_count: %d\n", num_count);
printf("sequence: \n");
for (i = num_count - 1; i >= 0; i--)
{
printf("%d ", a[i]);
}
printf("\n");
printf("inverted sequence: \n");
for (i = 0; i < num_count; i++)
{
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
希望对你有帮助。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询