一道c+语言 急急 编程

[复制链接]
查看11 | 回复2 | 2011-7-15 09:26:09 | 显示全部楼层 |阅读模式
/*任意一个四位数(数字不能全相同),
把所有数字从大到小排列,
再把所有数字从小到大排列,
用前者减去后者得到一个新的数。
重复对新得到的数进行上述操作,
7 步以内必然会得到 6174。
例如,输入四位数 6767:
7766 - 6677 = 1089       
9810 - 0189 = 9621       
9621 - 1269 = 8352       
8532 - 2358 = 6174       
7641 - 1467 = 6174
编程实现:
1)从键盘输入一个整数,若不符合条件,提示用户重新输入;
2)将上述每一步减法的过程显示在屏幕上;
3)由用户输入Y/N选择是否继续输入新的整数。
考察要点:整数各位数字的拆分、排序、函数的使用*/

回复

使用道具 举报

千问 | 2011-7-15 09:26:09 | 显示全部楼层
#include "iostream.h"#include "math.h"#include "iomanip.h"bool fun1(int x);void fun2(int x,int* a,int len);intfun3(int *a,int len);intfun4(int *a,int len);int main(){int x,max,min,a[4];char jixu;do{do{cout>x;}while(!fun1(x));while(x!=6174){fu...
回复

使用道具 举报

千问 | 2011-7-15 09:26:09 | 显示全部楼层
#include #define N 50void main(){ int i,k,m,n,num[N],*p; printf("please input the total of numbers:"); scanf("%d",&n); p=num; for(i=0;i#define N 50void main(){ int i,k,m,n,num[N],*p; printf("please input the total of numbers:"); scanf("%d",&n); p=num; for(i=0;i<n;i++)...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行