c语言中把一串数字反向输出的程序是什么?

2024-11-08 12:10:44
推荐回答(4个)
回答1:

#include
#define MAX 3 //定义你要输入整数的个数
int main()
{
int i, s[MAX];
for(i = 0; i < MAX; i++)
scanf("%d",&s[i]);
for(i = MAX-1; i >= 0; i--)
printf("%d ",s[i]);
printf("\n");
}

回答2:

include
void main()
{int a,b,c;
scanf("%d%d%d",&a,&b,&c);
printf("%d%d%d",c,b,a);
}

回答3:

#include
#include

int main()
{
int num;
scanf("%d",&num);
while(num!=0)
{
printf("%d",num%10);
num/=10;
}

system("pause");

}

回答4:

#include


int main()

{

int a = 0, b = 0, c = 0;


printf("Enter a two-digit number:");

scanf_s("%1d%1d%1d",&a,&b,&c);

printf("The reversal is:%1d%1d%1d",c,b,a);


return 0;

}