qfedu-c-level/day6/d6.c

34 lines
639 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
int main()
{
int nums[5][3] = {0};
int n;
for (int i = 0; i < 5; i++)
{
printf("请输入第%d个三位数", i + 1);
scanf("%d", &n);
int m[] = {100, 10, 1};
int j = 0;
while (n > 0)
{
nums[i][j] = n / m[j];
n %= m[j];
j++;
}
}
for (int i = 0; i < 5; i++)
{
// 判断这个三位数是否为回文数
if (nums[i][0] == nums[i][2])
continue;
for (int j = 0; j < 3; j++)
{
printf("%d ", nums[i][j]);
}
printf("\n");
}
}