乌拉尔山脉事件电影:C语言 输入一个整数,如何输出它的逆续数,比如12345,要求输出54321
来源:百度文库 编辑:神马品牌网 时间:2024/10/04 04:21:03
求它的各位数字,分别输出即可,比如12345:
12345%10求出个位数字5,输出;12345/10得1234,1234%10求出十位数字4,输出;1234/10得123,再求下去,不断重复即可求出各位数字。
char s[5]="12345";
int i;
for(i=s.strlen-1;i>=0;i--)
{
print("%c",s[i]);
}
如果你想多写点,自己改s里面的维数吧
JAVA,自己改把
//实现字符串的倒序输出
public class BackwardString {
public static void main(String[] args) {
System.out.print("请输入一句话:");
System.out.println();
String s = SavitchIn.readLine();
int n = s.length();
char a[] = new char[n];
for (int i = 0; i < n; i++) {
a[i] = s.charAt(i);
}
System.out.println(s + "倒序输出为:");
for (int i = n - 1; i > -1; i--) {
System.out.print(a[i]);
}
}
}
#include "stdafx.h"
int main()
{
int x;
scanf("%d",&x);
int digit;
int ret = 0;
while (x > 0)
{
digit = x%10;
ret = ret * 10 + digit;
printf("x = %d,digit = %d,ret = %d\n",x,digit,ret);
x /= 10;
}
printf("%d",ret);
getchar();
getchar();
return 0;
这个好像有简单了
C语言 输入一个整数,如何输出它的逆续数,比如12345,要求输出54321
用C语言编输入一个整数输出其位数
用C语言编输入一个整数输出其位数
在c 语言中输入n 个整数,相同的输出一个,计算个数
编写一个程序输入一个整数,将其逆序输出,输出格式为整数(用C语言)
用C 语言写出一个判素数的函数,在主函数输入一个整数,输出是否素数的信息
用C语言写一个判素数的函数,在主函数输入一个整数,输出是否素数的信息。
C语言,怎么用递归函数,把输入的一个十进制整数转换成二进制数输出
C语言,编一程序用递归函数,把输入的一个十进制整数转换成二进制数输出
用C语言编写一个程序,输入4个整数,按从大到小顺序输出!