文件名称:排列
下载
别用迅雷、360浏览器下载。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
介绍说明--下载内容均来自于网络,请自行研究使用
本题要求编写程序,将一个给定的整数插到原本有序的整数序列中,使结果序列仍然有序。
输入格式:
输入在第一行先给出非负整数N(<10);第二行给出N个从小到大排好顺序的整数;第三行给出一个整数X。
输出格式:
在一行内输出将X插入后仍然从小到大有序的整数序列,每个数字后面有一个空格。(Input sample: Five 12457 Three Output sample: 123457 Note: there is a "space" behind the last data of the problem. * / #include <stdio.h> #include <stdlib.h> #define N 10 Int main () {int a[N], I, N, X; Scanf ("%d", &n); For (i=0; i<n; i++) Scanf ("%d", &a[i]); Scanf ("%d", &x); For (i=n; i>0; i--) If (x>a[i-1]) Break; Else A[i]=a[i-1]; A[i]=x; For (i=0; i<=n; i++) Printf ("%d", a[i]); Note: the back / the last data to have a "space" Return 0; })
输入格式:
输入在第一行先给出非负整数N(<10);第二行给出N个从小到大排好顺序的整数;第三行给出一个整数X。
输出格式:
在一行内输出将X插入后仍然从小到大有序的整数序列,每个数字后面有一个空格。(Input sample: Five 12457 Three Output sample: 123457 Note: there is a "space" behind the last data of the problem. * / #include <stdio.h> #include <stdlib.h> #define N 10 Int main () {int a[N], I, N, X; Scanf ("%d", &n); For (i=0; i<n; i++) Scanf ("%d", &a[i]); Scanf ("%d", &x); For (i=n; i>0; i--) If (x>a[i-1]) Break; Else A[i]=a[i-1]; A[i]=x; For (i=0; i<=n; i++) Printf ("%d", a[i]); Note: the back / the last data to have a "space" Return 0; })
相关搜索: 简化的插入排序
(系统自动生成,下载前可以参看下载内容)
下载文件列表
文件名 | 大小 | 更新时间 |
---|---|---|
排列.docx | 12594 | 2018-03-21 |