| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 336 人关注过本帖
标题:[讨论] 在线等答案
收藏  订阅  推荐  打印 
maxkaoyan
Rank: 1
等级:新手上路
帖子:12
积分:220
注册:2005-4-22
[讨论] 在线等答案

请分别写出:
1.编写程序,实现将存放到变量n中的整数,逆序输出;
2.编写程序,实现将存放到变量n中的整数,逆序存放到变量m中,输出m;
2005-5-6 18:59
musicml
Rank: 3Rank: 3
等级:中级会员
帖子:273
积分:2830
注册:2005-4-2

//1.编写程序,实现将存放到变量n中的整数,逆序输出;

#include <stdio.h> #include <string.h> #include <stdlib.h>

void output_1_disorder(int num);

void output_1_disorder(int num) { char str[100]; itoa(num,str,10); strrev(str); puts(str); }

void main() { int num; puts("please enter the num:"); scanf("%d",&num); output_1_disorder(num); }

//2.编写程序,实现将存放到变量n中的整数,逆序存放到变量m中,输出m;

#include <stdio.h> #include <string.h> #include <stdlib.h>

void output_2_disorder(int num);

void output_2_disorder(int num) { char str[100]; int m; itoa(num,str,10); strrev(str); m=atoi(str); printf("m=%d\n",m); }

void main() { int num; puts("please enter the num:"); scanf("%d",&num); output_2_disorder(num); }


Every thing is possible.
2005-5-6 19:38
空前
Rank: 6Rank: 6
等级:金牌会员
帖子:1145
积分:11600
注册:2004-5-11

#include<stdio.h> main() {int n,a[20],i,j;

printf("Input a number:"); scanf("%d",&n); j=0; while(n) {a[j++]=n%10; n=n/10; } for(i=0;i<j;i++) printf("%d",a[i]);

printf("\n"); getch(); }

[此贴子已经被作者于2005-5-6 20:04:03编辑过]


2005-5-6 19:39
空前
Rank: 6Rank: 6
等级:金牌会员
帖子:1145
积分:11600
注册:2004-5-11

2:

#include&lt;stdio.h&gt;
main()
{int n,m,k;
printf("Input n=");
scanf("%d",&n);
k=0;
while(n)
{m=k*10+n%10;
n=n/10;
k=m;
}
printf("m=%d\n",m);
getch();
}

2005-5-6 19:42
wanwan520
Rank: 1
等级:新手上路
帖子:6
积分:160
注册:2005-4-17

#include<stdio.h> main() {long n,a[20],i=0,k,j;

printf("Input a number:"); scanf("%d",&n); j=0; while(n) { a[j++]=n%10;/*这句话我觉得挺经典的,谢谢楼上的~*/ n=n/10; } while(a[i]==0) /*这里是用来将形如18000的数打印成81*/ i++;

for(k=i;k<j;k++) printf("%d",a[k]);

printf("\n"); getch(); }

2005-5-7 21:51
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.068603 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved