当前位置: 代码迷 >> C语言 >> 求助小难题
  详细解决方案

求助小难题

热度:293   发布时间:2007-06-15 20:50:31.0
求助小难题

1.一维数组的操作,菜单方式实现如下功能:
(1)输入功能:用函数实现一维数组数据输入
(2)输出功能:用函数实现一维数组数据输出
(3)排序功能:对数组进行从小到大或从大到小排序
(4)检索功能:在已经排序的数据中查找某个数,如果找到显示其所在的下标,未找到显示‘“no found":
我请教了许多人,但都没有人能给出一个令人满意的答案!下面是给出了的部分程序:谁可以续完它呢?要能完成上面的功能要求!

#include<stdio.h>
#include<conio.h>
main()
{
int ch;
while(1){
clrscr();
printf("\n========== menu ============");
printf("\n 1.input");
printf("\n 2.modify");
printf("\n 3.output");
printf("\n 0.exit");
printf("\n============================");
printf("\n Your selection(0--3):");
ch=getch();
if(ch=='0'){
printf("\nDo you want to exit!");
break;
}
switch(ch){
case '1':clrscr();
printf("You selected 1.input.");
break;
case '2':clrscr();
printf("You selected 2.modify.");
break;
case '3':clrscr();
printf("You selected 3.output.");
break;
}
printf("\nPress any key to return the menu.");
getch();
}

搜索更多相关的解决方案: 难题  

----------------解决方案--------------------------------------------------------
以下是引用gxgx在2007-6-15 20:50:31的发言:

1.一维数组的操作,菜单方式实现如下功能:
(1)输入功能:用函数实现一维数组数据输入
(2)输出功能:用函数实现一维数组数据输出
(3)排序功能:对数组进行从小到大或从大到小排序
(4)检索功能:在已经排序的数据中查找某个数,如果找到显示其所在的下标,未找到显示‘“no found":
我请教了许多人,但都没有人能给出一个令人满意的答案!下面是给出了的部分程序:谁可以续完它呢?要能完成上面的功能要求!

#include<stdio.h>
#include<conio.h>
main()
{
int ch;
while(1){
clrscr();
printf("\n========== menu ============");
printf("\n 1.input");
printf("\n 2.modify");
printf("\n 3.output");
printf("\n 0.exit");
printf("\n============================");
printf("\n Your selection(0--3):");
ch=getch();
if(ch=='0'){
printf("\nDo you want to exit!");
break;
}
switch(ch){
case '1':clrscr();
printf("You selected 1.input.");
break;
case '2':clrscr();
printf("You selected 2.modify.");
break;
case '3':clrscr();
printf("You selected 3.output.");
break;
}
printf("\nPress any key to return the menu.");
}
getch();
}



注意格式...
格式理清.. 错误一下就看出来了...

注意我给你改的格式.. 样成习惯


----------------解决方案--------------------------------------------------------
  相关解决方案