为什么第二个scanf不执行呢?
来源:互联网 发布:博扬博格达诺维奇数据 编辑:程序博客网 时间:2024/04/29 09:15
2 #define MAX 1000 |
3 int isfull(int n);//judge if the list is full or not |- orderlist.c (/root/李志明)
4 void insert(int *p,int len,int i,int elem);//*p represent the first element'id of list,i represent what location do you want||- macro
to insert? elem represent what elementdo you want to insert? ||| MAX
5 void delete(int *pi,int len,int i);//*p represent the first element'id of list,i represent what location do you want to dele||
te? ||- function
6 int lookelem(int *p,int n,int elem);//what element do you want to look for in the list?;n represent the length of the list. ||| main
7 main(){ ||| isfull
8 int i,j,k; ||| insert
9 int loca,elem; ||| delete
10 int c; ||| lookelem
11 int s[MAX]; |
12 printf("please input list:"); | ~
13 for(i = 0;i < MAX;i++){ | ~
14 scanf("%d",&s[i]); | ~
15 if (s[i] == '\n') | ~
16 break; | ~
17 } | ~
18 printf("please choose: "); | ~
19 printf("0 represent you want to insert element.\n"); | ~
20 printf("1 represent you want to delete element.\n"); | ~
21 printf("2 represent you want to look element.\n"); | ~
22 scanf("%d",&c); | ~
23 // if((c =getchar()) == '0' ||'1'||'2'||'-1' ){ | ~
24 switch(c){ | ~
25 printf("please choose:"); | ~
26 case '0': | ~
27 printf("please input the location and element:"); | ~
28 scanf("%d,%d",&loca,&elem); | ~
29 insert(s,i,loca,elem); | ~
30 case'1': | ~
31 printf("please input the location and element:"); | ~
32 scanf("%d",&loca); | ~
33 delete(s,i,loca); | ~
34 case'2': | ~
35 printf("please input element:"); | ~
36 scanf("%d",&elem); | ~
37 k = lookelem(s,i,elem); | ~
38 if(j == 0 ) | ~
39 printf("the list have no element you want look\n"); | ~
40 else | ~
41 printf("the list is %d",j); | ~
42 default: | ~
43 return -1; | ~
44 } | ~
45 // } | ~
46 // else | ~
47 // printf("you input error num.\n");
printf("the last list is:\n"); ||
49 for(k = 0;k < MAX;k++){ ||- function
50 printf("%d",s[k]); ||| main
51 if(s[k] == '\0') ||| isfull
52 break; ||| insert
53 } ||| delete
54 } ||| lookelem
55 |
56 int isfull(int n){ | ~
57 if(n > MAX) | ~
58 printf("the list is full"); | ~
59 else | ~
60 return 0; | ~
61 } | ~
62 | ~
63 void insert(int *p,int len,int i,int elem){ | ~
64 int j,k; | ~
65 for(k = len;k > i;k--) | ~
66 *(p+k) = *(p+k); | ~
67 *(p+k) = elem; | ~
68 isfull(len + 1); | ~
69 printf("the list is:\n"); | ~
70 for(j = 0;j < len+2;j++) | ~
71 printf("%d",*(p+j)); | ~
72 } | ~
73 | ~
74 void delete(int *pi,int len,int i){ | ~
75 int j,k; | ~
76 for(j = len;j < i;j--) | ~
77 *(pi+j) = *(pi+j-1); | ~
78 printf("now the list is:\n"); | ~
79 for(k = 0;k < len;k++) | ~
80 printf("%d",*(pi+k)); | ~
81 } | ~
82 | ~
83 int lookelem(int *p,int n,int elem){ | ~
84 int k; | ~
85 for(k = 0;k < n+1;k++){ | ~
86 if(elem = *(p+k)) | ~
87 return *p; | ~
88 else | ~
89 return 0; | ~
90 } | ~
91 } | ~
orderlist.c
- 为什么第二个scanf不执行呢?
- 为什么不死锁呢?
- 为什么就不紧张呢?
- 为什么不发博客呢
- jquery为什么不执行
- 调用了bindService()之后,程序执行了Service里的onBind(),但是为什么不执行ServiceConnection对象接口onServiceConnected()呢?
- 为什么freetextbox不显示按钮呢
- 易飞扬为什么不出入门教程呢??
- 为什么不安装公共JRE呢?
- 看贴回贴能拿分。为什么不回?你说呢
- 找不到更好的?为什么不试一试呢?
- 职场老司机:能走捷径,为什么不呢?
- C++为什么不提倡使用scanf和printf函数
- C++为什么不提倡使用scanf和printf函数
- 两种写法,为什么第二种就总崩溃呢
- 为什么printf()用%f输出double型,而scanf却用%lf呢?
- 为什么printf()用%f输出double型,而scanf却用%lf呢?
- 为什么printf()用%f输出double型,而scanf却用%lf呢
- inittab文件诠释
- 《Windows游戏编程大师技巧》 四、GDI、控件和突发奇想
- Java compiler level does not match the version of the installed Java project facet. 解决办法
- 第九周实验报告(任务3)
- he type java.lang.Object cannot be resolved解决方法
- 为什么第二个scanf不执行呢?
- n是2的几次方?
- 使用按钮选择本地文件
- 第九周实验报告(任务5)
- 【转】秒杀多线程第七篇 经典线程同步 互斥量Mutex
- 随时随地被追踪:智能手机是天使or魔鬼?
- C/C++生成随机数的方法浅析
- 【转】秒杀多线程第二篇 多线程第一次亲密接触 CreateThread与_beginthreadex本质区别
- 一些常用的统计量指标