当前位置: 代码迷 >> C语言 >> [讨论]很急的程序,帮我看看
  详细解决方案

[讨论]很急的程序,帮我看看

热度:157   发布时间:2005-11-25 17:56:00.0
[讨论]很急的程序,帮我看看

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





#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  动态  最好  

----------------解决方案--------------------------------------------------------
node=getch( ); /*接受输入的ASCII字符*/
switch (node)
----------------解决方案--------------------------------------------------------
  相关解决方案