简单的数列排序
来源:互联网 发布:网络订餐食品安全现状 编辑:程序博客网 时间:2024/05/01 11:21
#include<stdio.h>
void menu(){
printf("1.input a new list\n");
printf("2.output my list\n");
printf("3.insert\n");
printf("4.delete\n");
printf("0.quit\n");
}
void main(){
int list[100];
int length;
int temp,i;
int pos,newnum,choice;
char c;
menu();
printf("please choice\n");
scanf("%d",&choice);
while(choice != 0){
switch(choice){
case 1:
printf("please input your length (max :100)\n");
scanf("%d",&length);
printf("please input %d numbers?\n",length);
i =0;
while(i<length){
scanf("%d",&list[i]);
i++;
}
break;
case 2:
if(length<0){
printf("please input a biao first");
break;
}else{
printf("your list :\n");
i=0;
while(i<length){
printf("%d",list[i]);
i++;
}
break;}
case 3:
if(length<0){
printf("please en 1 input a biao");
break;
}else{
printf("please your position\n");
scanf("%d",&pos);
printf("please insert new number \n");
scanf("%d",&newnum);
while(pos<1 || pos >length+1){
printf("wrong position ,please inout again\n");
scanf("%d",&pos);
}
if(pos>0 || pos<length){
while(i>pos){
list[i+1]=list[i];
i--;
}
list[pos-1]=newnum;
length++;
}
}
break;
case 4:
if(length<0){
printf("please input a biao first");
break;
}else{
printf("please input you want to delete position\n");
scanf("%d",&pos);
while(pos<1 || pos >length+1){
printf("wrong position ,please inout again\n");
scanf("%d",&pos);
}
for(i=pos;i<length;i++){
list[i-1]=list[i];
}
length--;
break;
}}
printf("\n");
menu();
scanf("%d",&choice);
}
}
void menu(){
printf("1.input a new list\n");
printf("2.output my list\n");
printf("3.insert\n");
printf("4.delete\n");
printf("0.quit\n");
}
void main(){
int list[100];
int length;
int temp,i;
int pos,newnum,choice;
char c;
menu();
printf("please choice\n");
scanf("%d",&choice);
while(choice != 0){
switch(choice){
case 1:
printf("please input your length (max :100)\n");
scanf("%d",&length);
printf("please input %d numbers?\n",length);
i =0;
while(i<length){
scanf("%d",&list[i]);
i++;
}
break;
case 2:
if(length<0){
printf("please input a biao first");
break;
}else{
printf("your list :\n");
i=0;
while(i<length){
printf("%d",list[i]);
i++;
}
break;}
case 3:
if(length<0){
printf("please en 1 input a biao");
break;
}else{
printf("please your position\n");
scanf("%d",&pos);
printf("please insert new number \n");
scanf("%d",&newnum);
while(pos<1 || pos >length+1){
printf("wrong position ,please inout again\n");
scanf("%d",&pos);
}
if(pos>0 || pos<length){
while(i>pos){
list[i+1]=list[i];
i--;
}
list[pos-1]=newnum;
length++;
}
}
break;
case 4:
if(length<0){
printf("please input a biao first");
break;
}else{
printf("please input you want to delete position\n");
scanf("%d",&pos);
while(pos<1 || pos >length+1){
printf("wrong position ,please inout again\n");
scanf("%d",&pos);
}
for(i=pos;i<length;i++){
list[i-1]=list[i];
}
length--;
break;
}}
printf("\n");
menu();
scanf("%d",&choice);
}
}
1 0
- 简单的数列排序
- Project 9:两种简单数列排序
- 可扩展的数列排序
- 一个简单的数列求和
- CJOJ 2398 简单的数列
- 数列排序(数列的升序和降序)
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- 数列排序
- ceph存储 dmesg和addr2line分析bug以及so动态库崩溃示例
- React Native Flexbox布局
- 【扩展】浏览器对应的selenium版本问题
- Django项目调试心得
- 工具类: EditText保留小数点后3位
- 简单的数列排序
- 【模板】二维rmq
- Android 内容提供器小结
- 计算机原理课程:1
- MySQL不支持 SELECT INTO FROM 这种语句,MySQL SELECT INTO FROM 语句的替代方案
- typedef定义新的类型标识符
- 使用fastboot命令刷机流程详解
- 工作流管理系统开发之十四 流程设计器属性页面之实现篇
- Android加载Gif图片的一般方法:Movie实现