11问答网
所有问题
当前搜索:
c语言输入1234反向输出4321
用
c语言
编程 求一个数的逆序数。(如
1234
的逆序数是
4321
)
答:
include <stdio.h> include <string.h> include <stdlib.h> void main(){ char array[10];int k;scanf("%d", &k);itoa(k, array, 10);k = strlen(array);while(k>=0){ printf("%
c
", array[k-1]);k--;} //如果想逆序
输出
数是整型数,可以用atoi()函数转换回来 } ...
...如
输入
m=
1234
,则m=
4321
,是c++不是
c语言
~谢谢高手啦~
答:
include <iostream> include <string> include <cstdlib> include <vector> using namespace std;int main(){ string input;getline(cin, input);copy(input.rbegin(), input.rend(), ostream_iterator<char>(cout, ""));system("pause");return 0;} ...
C语言中
怎样求一个四位数的逆序数,如
输入1234
就能
输出4321
?
答:
办法很多,举一例:include <stdio.h>int main(int argc,char *argv[]){ int n; printf("Enter a positive integer...\nn="); if(scanf("%d",&n)!=1 || n<1){ printf("Input error, exit...\n"); return 0; } for(;n;printf("%d ",n%10),n/=10)...
用
C语言
编一个程序,逆序
输出
一个正整数!eg:
1234
->
4321
答:
include "stdio.h"int main(){ int a,b=0;scanf("%d",&a);while(a){ b*=10;b+=a%10;a/=10;} printf("\n%d",b);return 0;}
任意
输入
一个四位数,逐个
输出
数字。
C语言
编程题
答:
源程序如下:include <stdio.h> void main(){ int num;printf("please a 四wei shu:");scanf("%d",&num);while (num>0)/*num大于0就不停循环*/ { printf("%d",num%10);/*
输出
个位*/ num/=10;/*除以10*/ } } vc++6.0测试通过
输入
:
1234
输出:
4321
...
关于
C语言
答:
getchar()得到的
1234
在字符串数组中是“1234” , 4在低位,1在高位。而putchar()时,从字符串数组的低位开始
输出
,所以得到
4321
12340怎么
输出
0
4321c语言
答:
main(){ string str="12340"; int length = str.length(); for(int i = 0; i < length;++i) { printf("%c",str[length - i - 1]); } }
急求,C++,我的程序错在哪里?将
输入
的整数倒置,例:
1234
→
4321
_百度...
答:
在你的基础上改了一些,代码如下:include<stdio.h>#include<math.h>int main(){ int i,j=0,a,b,
c
=0; printf("请
输入
一个整数:"); scanf("%d",&i); if(i<0) i=fabs(i); //你在后面赋值时,i已经发生改变 a=i; for(;i/10!=0;i=i/10) j++;...
C语言
如何倒置一个数
输出
(如123-->321
1234
-->
4321
) 有个do while 语...
答:
代码如下。。。我测试过了。。。include "stdio.h"main(){ int a,tmp;printf("please input a data : \n");scanf("%d",&a);tmp = a;do{ printf("%d",tmp%10);tmp = tmp/10;}while(tmp!=0);getch();} 希望对你有帮助。。。仍有问题可以HI我。。。
用递归函数
反向输出
一个正整数n。函数声明为void Reverse(int n...
答:
include <stdio.h>void Reverse(int n){if(n>=0 && n<=9)printf("%d\n",n);else{printf("%d",n%10);Reverse(n/10);}}int main(){int n;scanf("%d",&n);Reverse(n);return 0;}示例运行结果:
1234
4321
123456 654321 ...
<涓婁竴椤
1
2
3
4
5
6
7
8
9
10
涓嬩竴椤
灏鹃〉
其他人还搜