| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 787 人关注过本帖
标题:将数字插入有序排放的数列
取消只看楼主 加入收藏
wxz11191975
Rank: 1
等 级:新手上路
帖 子:98
专家分:0
注 册:2011-6-20
结帖率:85.29%
收藏
 问题点数:0 回复次数:1 
将数字插入有序排放的数列
输入一个数到有序排放的数列中,插入后,数列仍然有序
#include <stdio.h>
#include <stdlib.h>

#define NUM 10

void insert(int *a,int x)
{int i,j=0;
 int *n;
 for(i=0;i<NUM; i++)
  { for(j=0;x<a[i];j++) j=i-1;}
 for(i=NUM;i>=j;j--)a[i+1]=a[i];
 a[j]=x;
 n[NUM+1]=a[i+1];
 }

void arrout(int a[],int n)
{int i;
for(i=0;i<n;i++) printf("%5d",a[i]);
printf("\n");
}

main()
{ int i,j,a[NUM]={21,34,44,56,67,78,89,90,911,912};
  int n[NUM+1];
  printf("output the primary numbers:\n");
  arrout(a,NUM);
  printf("input the inserted number:\n");
  scanf("%d",&j);
  printf("the number needed to insert is: %d\n",j);
  insert(a,j);
  printf("output the new nubmers:\n");
  arrout(n,NUM+1);
  system("PAUSE");   
  return 0;
}

折腾半天了,毛病出在insert那个函数里,compile可以过,但是程序执行到 insert那里不走。怎么改?  
搜索更多相关主题的帖子: 女孩 苹果 include insert 青春 
2011-07-03 17:08
wxz11191975
Rank: 1
等 级:新手上路
帖 子:98
专家分:0
注 册:2011-6-20
收藏
得分:0 
Thanks for all help!
2011-07-05 19:01
快速回复:将数字插入有序排放的数列
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016034 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved