| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 483 人关注过本帖
标题:[讨论]很急的程序,帮我看看
只看楼主 加入收藏
sailer
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2005-10-12
收藏
 问题点数:0 回复次数:1 
[讨论]很急的程序,帮我看看

我想用动态数组存放和比较大小后排序得到的有序数列。数组存放你想排列的数,数是从键盘输入。实现:当你输的不是数字时提示你,我打问号的地方就不太会了,请大家帮我补充。谢谢啊~!~!
最好是说明以下。





#include "alloc.h"
void bubblesort(int *list,int index)
{
int i,j,change,temp;
while(!change)
{
change=1;
for(j=index;j>0;j--)
{
for(i=0;i<j-1;i++)
{
if(list[i]<list[i+1])
{
temp=list[i];
list[i]=list[i+1];
list[i+1]=temp;
change=0;
printf("\n current sortting rest is:") ;
for(i=0;i<index;i++)
printf("%d",list[i]);
}
}
}
}
}

void main()
{
int []list=malloc(sizeoe(int)*n);
int i,index;
int node; /* 存储暂寸变量 */
char string;
printf("please enter the value of you want to sort:(数字)");
node=getch( ); ??????????
switch () ???????????
while(node!=string)
{
list[index]=node;
index=index+1;

}
bubblesort(list ,index);
printf("\n final sqrting rest is:");
for(i=0;i<index;i++)
{
printf("%d\t",list[i]);
}
}


[此贴子已经被作者于2005-11-29 22:23:56编辑过]

搜索更多相关主题的帖子: 键盘 include change 动态 最好 
2005-11-25 17:56
原汁原味
Rank: 1
来 自:湖南省永州市
等 级:新手上路
帖 子:62
专家分:0
注 册:2005-11-17
收藏
得分:0 
node=getch( ); /*接受输入的ASCII字符*/
switch (node)

我们不能控制 时间的前进, 但我们可以掌握时间的运用!
2005-11-25 20:34
快速回复:[讨论]很急的程序,帮我看看
数据加载中...
 
   



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

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