已有一个排好序的序列,输入一个数插入到该序列中,使其仍然保持有序.

[复制链接]
查看11 | 回复0 | 2008-4-20 21:07:33 | 显示全部楼层 |阅读模式
#include #define N 9void main() { int i,j; int a[N+1]={0},b;printf("please input %d numbers from small to big:",N);for(i=0;ij;i--)a=a[i-1];a[j]=b;for(i=0;i<N+1;i++)printf("%d ",a); printf("\n");}/*运行结果:please input 9 numbers from small to big:1 3 5 7 9 11 13 15 17please input the number insert:121 3 5 7 9 11 12 13 15 17*/
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行