博客班级 | https://edu.cnblogs.com/campus/ahgc/AHPU-se-JSJ18 |
---|---|
作业要求 | https://edu.cnblogs.com/campus/ahgc/AHPU-se-JSJ18/homework/11478 |
作业目标 | <编写一个ATM管理系统> |
学号 | <3180701107> |
一.题目要求 |
编写一个ATM管理系统,语言不限,要求应包括以下主要功能:
(1)开户,销户
(2)查询账户余额
(3)存款
(4)取款
(5)转账(一个账户转到另一个账户)等...
二.代码提交及运行截图
1. #include<stdio.h>
2. #include<string.h>
3. #include<stdlib.h>
4.
5. struct per //定义结构体
6. {
7. char name[20];
8. char ID[20];
9. int money;
10. char mima[6];
11. struct per * next;
12. };
13. typedef struct person //定义另一结构体
14. {
15. struct per kehu;
16. struct person *next;
17. }L;
18.
19. void chaxun(struct per *head); //各个函数的声明
20. void kaihu(struct per *head);
21. void denglu(struct per *head);
22. void caidan(struct per *head);
23. void qukuan(struct per *head);
24. void xgmm(struct per *head);
25. void cunkuan(struct per *head);
26. void zhuanzhang(struct per *head);
27. void chuangjian(struct person **Phead);
28. void shuchu(struct person *Phead);
29. void shanchu(struct person **Phead);
30. void zengjia(struct person **Phead);
31. void chaxun1(struct person *Phead);
32. void chaxun2(struct person *Phead);
33. void chaxun3(struct person *Phead);
34. void tuichu();
35. void menu();
36.
37.
38.
39.
40. /*主函数*/
41. //
42.
43. void main()
44. {
45. char x;
46. char choose; //choose为定义输入选择的变量
47. int flag=1;
48. struct person *Phead=NULL; //Phead为定义二层头指针
49. struct per *head=NULL; //head为定义一层头指针
50. printf("*****************************
");
51. printf("**欢迎使用ATM自动取款机系统**
");
52. printf("*****************************
");
53. printf("——————————————
");
54. printf("| 1 开户 |
");
55. printf("——————————————
");
56. printf("| 2 登陆 |
");
57. printf("——————————————
");
58. printf("| 3 前台客户信息查询中心|
");
59. printf("——————————————
");
60. printf("| 4 请选择您的需求 |
");
61. printf("——————————————
");
62. scanf("%s",&x);
63. system("cls");
64.
65. switch(x)
66. {
67. case '1':system("cls");
68. kaihu(head); //调用开户函数
69. break;
70.
71. case '2':system("cls");
72. denglu(head); //调用登陆函数
73. break;
74.
75. case '3':system("cls");
76. menu(); //调用后台菜单函数
77. break;
78. }
79. while(flag)
80. {
81. system("cls");
82. menu(); //调用后台菜单函数
83. choose=getchar();
84. switch(choose)
85. {
86. case '1':chuangjian(&Phead);
87. shuchu(Phead); //调用后台输出函数
88. system("pause");
89. system("cls");
90. break;
91. case '2':chaxun1(Phead); //调用后台卡号查询函数
92. system("pause");
93. system("cls");
94. break;
95. case '3':chaxun2(Phead); //调用后台姓名查询函数
96. system("pause");
97. system("cls");
98. break;
99. case '4':
100. chaxun3(Phead); //调用后台余额查询函数
101. system("pause");
102. system("cls");
103. break;
104. case '5':shanchu(&Phead); //调用后台删除用户函数
105. system("pause");
106. system("cls");
107. break;
108. case '6':
109. zengjia(&Phead); //调用后台增加用户函数
110. system("pause");
111. system("cls");
112. break;
113. case '7':shuchu(Phead); //调用后台输出函数函数
114. system("pause");
115. system("cls");
116. break;
117. case '8':shuchu(Phead);
118. system("pause");
119. system("cls");
120. break;
121. case '0':flag=0;
122. printf("The end.
");
123. break;
124. }
125. }
126. }
127. /*开户函数*/
128.
129. void kaihu(struct per *head)
130. {
131. head=NULL;
132. FILE *fp; //定义文件指针
133. struct per *p1=NULL,*p2=NULL; //p1,p2为定义链表指针
134. p1=(struct per*)malloc(sizeof(struct per)); //开辟内存单元
135. printf("请输入您的姓名:
"); //请数据输入链表中
136. scanf("%s",p1->name);
137. printf("请设置您的卡号:
");
138. scanf("%s",p1->ID);
139. printf("请设置您银行卡密码:
");
140. scanf("%s",p1->mima);
141. p1->money=0;
142. p1->next=NULL;
143. printf("您的个人信息为");
144. printf("姓名:%s
卡号:%s
余额:%4d
",p1->name,p1->ID,p1->money);
145. if(NULL==head) //为新用户开辟内存单元
146. {
147. head=(struct per *)malloc(sizeof(struct per));
148. head->next=p1; //进行头插法,将其作为第一个节点
149. }
150. else //为新增客户开辟内存单元
151. {
152. for(p2=head;p2->next!=NULL;p2=p2->next); //进行尾插
153. p2->next=p1;
154. }
155. if((fp=fopen("save.txt","ab+"))==NULL) //打开文件
156. {
157. printf("cannot poen file
");
158. return;
159. }
160. if(fwrite(p1,sizeof(struct per),1,fp)!=1) //将链表信息写入文件中
161. printf("file write error
");
162. fclose(fp);
163. printf("
");
164. printf("恭喜您开户成功,请登录
");
165. system("pause");
166. system("cls");
167. denglu(head);
168. }
169.
170.
171. //登陆函数
172. /
173. void denglu(struct per *head)
174. {
175. char d[20];
176. char mima[20];
177. int i,j;
178. FILE *fp; //定义文件指针
179. struct per *p,*q=NULL;
180. if((fp=fopen("save.txt","rb+"))==NULL) //打开一个二进制文件,为读方式
181. {
182. printf("不能打开文件
"); //如不能打开,则结束程序
183. }
184. p=(struct per*)malloc(sizeof(struct per)); //申请空间
185. head=p;
186. while(!feof(fp)) //循环读数据直到文件尾结束
187.
188. {
189. if(1!=fread(p,sizeof(struct per),1,fp))
190. break; //如果没读到数据,跳出循环
191. p->next=(struct per *)malloc(sizeof(struct per)); //为下一个结点申请空间
192. q=p; //保存当前节点的指针,作为下一结点的前驱
193. p=p->next; //指针后移,新读入数据链到当前表尾
194.
195. }
196. q->next=NULL; //最后一个结点的后继指针为空
197. fclose(fp);
198. printf(" **********************
");
199. printf(" ***欢迎来到建设银行***
");
200. printf(" **********************
");
201. for(j=1;j<4;j++) //限制卡号输入的次数的循环
202. {
203. printf("请输入您的卡号
");
204. scanf("%s",d);
205. for(q=head;q!=NULL;q=q->next) //遍历链表
206. {
207. if(strcmp(q->ID,d)!=0) //核对账号
208. {
209. continue; //跳出循环
210. }
211. else
212. {
213. for(i=1;i<4;i++) //限制密码输入的次数的循环
214. {
215. printf("
请输入您的密码
");
216. scanf("%s",mima);
217. if(strcmp(q->mima,mima)!=0) //核对密码
218. {
219. printf("密码不正确。请重新输入密码
");
220. system("pause");
221. system("cls");
222. continue; //若密码不对,跳出循环
223. }
224. else
225. {
226. system("cls");
227. caidan(head); //调用菜单函数
228. }
229. }
230. printf("
您输入密码三次错误,谢谢光临
");
231. system("pause");
232. system("cls");
233. exit(0);
234. }
235. }
236.
237.
238. printf("
您输入的卡号有误,请重试
");
239. system("pause");
240. system("cls");
241. }
242. printf("您的卡号三次输入错误,谢谢使用
");
243. exit(0);
244. }
245.
246.
247.
248. //银行菜单函数
249. /
250. void caidan(struct per *head)
251. {
252. head=NULL;
253. int i; //i为客户选择输入的变量
254. while(1)
255. {
256. printf("请选择您需要的业务
"); //银行业务菜单
257. printf("*********************************
");
258. printf("** 1 取款 ***** 2 查询 **
");
259. printf("*********************************
");
260. printf("** 3 转账 ***** 4 修改密码**
");
261. printf("*********************************
");
262. printf("** 5 存款 ***** 6 退出 **
");
263. printf("*********************************
");
264. scanf("%d",&i);
265. if(i<6||i>0)
266. {
267. switch(i)
268. {
269. case 1:qukuan(head); //调用银行取款函数
270. system("pause");
271. system("cls");
272. break;
273. case 2:system("cls");
274. chaxun(head); //调用银行查询函数
275. break;
276. case 3:system("cls");
277. zhuanzhang(head); //调用银行转账函数
278. break;
279. case 4:system("cls");
280. xgmm(head); //调用银行修改密码函数
281. break;
282. case 5:system("cls");
283. cunkuan(head); //调用银行存款函数
284. break;
285. case 6:system("cls");
286. tuichu(); //调用银行退出函数
287. break;
288. }
289. }
290. else
291. {
292. printf("您的输入有误
");
293. system("pause");
294. system("cls");
295. }
296. }
297. }
298.
299.
300. //银行取款函数
301. //
302. void qukuan(struct per *head)
303. {
304. head=NULL; //head为链表头指针
305. int i;
306. FILE *fp; //定义文件指针
307. struct per *p,*q=NULL;
308. if((fp=fopen("save.txt","rb+"))==NULL) //打开一个二进制文件,为读方式
309. {
310. printf("不能打开文件
"); //如不能打开,则结束程序
311. }
312. p=(struct per*)malloc(sizeof(struct per)); //申请空间
313. head=p;
314. while(!feof(fp)) //循环读数据直到文件尾结束
315. {
316. if(1!=fread(p,sizeof(struct per),1,fp))
317. break; //如果没有读到数据,跳出循环
318. p->next=(struct per *)malloc(sizeof(struct per)); //为下一个结点申请空间
319. q=p; //保存当前结点的指针,作为下一个结点的前驱
320. p=p->next; //指针后移,新读入数据链到当前表尾
321. }
322. q->next=NULL; //最后一个结点的后继指针为空
323. fclose(fp);
324. system("cls");
325. printf("************************************
");
326. printf("** 1: 100元 ***** 2:200元 **
");
327. printf("************************************
");
328. printf("** 3: 300元 ***** 4:400元 **
");
329. printf("************************************
");
330. printf("** 5: 500元 ***** 6:600元 **
");
331. printf("************************************
");
332. printf("请按要求选择您要取款的金额
");
333. scanf("%d",&i);
334. if(i>6||i<=0) //限制输入范围
335. {
336. printf("对不起,您的输入有误
");
337. return;
338. }
339. else
340. {
341. i=100*i; //对应选项乘以一百为取款金额
342. if(i>q->money)
343. {
344. printf("对不起,您的金额不足
");
345. system("pause");
346. system("cls");
347. caidan(head); //调用取款机菜单函数
348. }
349. else
350. {
351. q->money-=i; //对金额进行处理
352. if((fp=fopen("save.txt","wb+"))==NULL) //打开文件
353. {
354. printf("cannot open file
");
355. return;
356. }
357. if(fwrite(q,sizeof(struct per),1,fp)!=1) //将修改的信息重新写入文件
358. printf("file write error
");
359. printf("您已经成功取走%d元
");
360. q->next=NULL;
361. fclose(fp); //关闭文件
362. }
363.
364. }
365. }
366.
367.
368. //银行转账函数
369. /
370. void zhuanzhang(struct per *head)
371. {
372. head=NULL;
373. FILE *fp; //定义文件指针
374. struct per *p,*q=NULL;
375. if((fp=fopen("save.txt","rb+"))==NULL) //打开一个二进制文件,为读方式
376. {
377. printf("不能打开文件
"); //如不能打开,则结束程序
378. }
379. p=(struct per*)malloc(sizeof(struct per)); //申请空间
380. head=p;
381. while(!feof(fp)) //循环读数据直到文件尾结束
382. {
383. if(1!=fread(p,sizeof(struct per),1,fp))
384. break; //如果没读到数据,跳出循环
385. p->next=(struct per *)malloc(sizeof(struct per)); //为下一个结点申请空间
386. q=p; //保存当前结点的指针,作为下一个结点的前驱
387. p=p->next; //指针后移,新读入数据链到当前表尾
388. }
389. q->next=NULL; //最后一个结点的后继指针为空
390. fclose(fp);
391. int i,j,k;
392. printf("请输入帐号号码
");
393. scanf("%d",&i);
394. printf("请再次输入帐号号码
"); //核对卡号
395. scanf("%d",&j);
396. if(i!=j)
397. {
398. printf("两次账号不同,请重新输入
");
399. zhuanzhang(head);
400. }
401. else
402. {
403. system("cls");
404. printf("************************************
");
405. printf("** 1: 100元 ***** 2:200元 **
");
406. printf("************************************
");
407. printf("** 3: 300元 ***** 4:400元 **
");
408. printf("************************************
");
409. printf("** 5: 500元 ***** 6:600元 **
");
410. printf("************************************
");
411. printf("请输入转账金额
");
412. scanf("%d",&k);
413. if(k>6||k<=0)
414. {
415. printf("对不起,您的输入有误
");
416. return;
417. }
418. else
419. {
420. k=k*100;
421. if(k>q->money) //对余额进行判断
422. {
423. printf("对不起,您的余额不足
");
424. system("pause");
425. system("cls");
426. caidan(head);
427. }
428. else
429. {
430. printf("您已成功转账%d元
",k);
431. q->money-=k;
432. if((fp=fopen("save.txt","wb+"))==NULL)
433. {
434. printf("cannot open file
");
435. return;
436. }
437. if(fwrite(q,sizeof(per),1,fp)!=1) //将数据重新写入文件
438. printf("file write error
");
439. q->next=NULL;
440. fclose(fp);
441. system("pause");
442. system("cls");
443. }
444. }
445. }
446. }
447.
448.
449.
450. //银行查询函数
451. /
452. void chaxun(struct per *head)
453. {
454. head=NULL; //链表头指针
455. FILE *fp; //定义文件指针
456. struct per *p,*q=NULL;
457. if((fp=fopen("save.txt","rb+"))==NULL) //打开一个二进制文件,为读方式
458. {
459. printf("不能打开文件
"); //如不能打开,则结束程序
460. }
461. p=(struct per*)malloc(sizeof(struct per)); //申请空间
462. head=p;
463. while(!feof(fp)) //循环读数据直到文件尾结束
464. {
465. if(1!=fread(p,sizeof(struct per),1,fp))
466. break; //如果没读到数据,跳出循环
467. p->next=(struct per *)malloc(sizeof(struct per)); //为下一个结点申请空间
468. q=p; //保存当前结点的指针,作为下一个结点的前驱
469. p=p->next; //指针后移,新读入数据链到当前表尾
470. }
471. q->next=NULL; //最后一个结点的后继指针为空
472. fclose(fp);
473. printf("您卡上原有余额%d元
",q->money);
474. system("pause");
475. system("cls");
476. }
477.
478.
479. //银行修改密码函数
480. //
481.
482. void xgmm(struct per *head)
483. {
484. head=NULL; //链表头指针
485. char mima[20];
486. FILE *fp; //定义文件指针
487. struct per *p,*q=NULL;
488. if((fp=fopen("save.txt","rb+"))==NULL) //打开一个二进制文件,为读方式
489. {
490. printf("不能打开文件
"); //如不能打开,则结束程序
491. }
492. p=(struct per*)malloc(sizeof(struct per)); //申请空间
493. head=p;
494. while(!feof(fp)) //循环读数据直到文件尾结束
495. {
496. if(1!=fread(p,sizeof(struct per),1,fp))
497. break; //如果没读到数据,跳出循环
498. p->next=(struct per *)malloc(sizeof(struct per)); //为下一个结点申请空间
499. q=p; //保存当前结点的指针,作为下一个结点的前驱
500. p=p->next; //指针后移,新读入数据链到当前表尾
501. }
502. q->next=NULL; //最后一个结点的后继指针为空
503. fclose(fp);
504. printf("请输入您的原密码
");
505. scanf("%s",mima);
506. if(strcmp(q->mima,mima)==0) //核对密码
507. {
508. {
509. printf("密码正确
");
510. printf("请输入您的新密码:
");
511. scanf("%s",q->mima);
512. if((fp=fopen("save.txt","wb+"))==NULL) //文件头指针
513. {
514. printf("cannot open file
");
515. }
516. if(fwrite(q,sizeof(struct per),1,fp)!=1) //将修改的密码重新写入文件
517. printf("file write error
");
518. fclose(fp);
519. printf("修改密码成功
");
520. }
521. }
522. else
523. {
524. printf("您输入的密码与原密码不同
");
525. return;
526. system("pause");
527. }
528. q->next=NULL;
529. }
530.
531.
532. //银行存款函数
533.
534.
535.
536. void cunkuan(struct per *head)
537. {
538. int i;
539. head=NULL; //链表头指针
540. FILE *fp; //定义文件指针
541. struct per *p,*q=NULL;
542. if((fp=fopen("save.txt","rb+"))==NULL) //打开一个二进制文件,为读方式
543. {
544. printf("不能打开文件
"); //如不能打开,则结束程序
545. }
546. p=(struct per*)malloc(sizeof(struct per)); //申请空间
547. head=p;
548. while(!feof(fp)) //循环读数据直到文件尾结束
549. {
550. if(1!=fread(p,sizeof(struct per),1,fp))
551. break; //如果没读到数据,跳出循环
552. p->next=(struct per *)malloc(sizeof(struct per)); //为下一个结点申请空间
553. q=p; //保存当前结点的指针,作为下一个结点的前驱
554. p=p->next; //指针后移,新读入数据链到当前表尾
555. }
556. q->next=NULL; //最后一个结点的后继指针为空
557. fclose(fp);
558. system("cls");
559. printf("您卡上原有余额%d元
",q->money);
560. printf("************************************
");
561. printf("** 1: 100元 ***** 2:200元 **
");
562. printf("************************************
");
563. printf("** 3: 300元 ***** 4:400元 **
");
564. printf("************************************
");
565. printf("** 5: 500元 ***** 6:600元 **
");
566. printf("************************************
");
567. printf("请选择您要存入的余额
");
568. scanf("%d",&i);
569. if(i>6||i<=0)
570. {
571. printf("对不起,您的输入有误
");
572. return;
573. }
574. else
575. {
576. i=100*i;
577. q->money+=i;
578. if((fp=fopen("save.txt","wb+"))==NULL) //打开文件
579. {
580. printf("cannot open file
");
581. }
582. if(fwrite(q,sizeof(struct per),1,fp)!=1) //将修改的密码重新写入文件
583. printf("file write error
");
584. printf("您已经成功存取%d元
",i);
585. q->next=NULL;
586. fclose(fp);
587. system("pause");
588. system("cls");
589. }
590. }
591.
592.
593.
594. //退出银行函数
595. ///
596. void tuichu()
597. {
598. printf("谢谢使用
");
599. exit(0);
600. }
601.
602. //后台运行菜单函数
603. ///
604. void menu()
605. {
606. printf("****************欢迎来到建设银行取款机系统****************
");
607. printf("**************************************************
");
608. printf("**** 1 建立信息并显示 ****** 2 卡号查询信息 ****
");
609. printf("**************************************************
");
610. printf("**** 3 姓名查询信息 ****** 4 余额查询信息 ****
");
611. printf("**************************************************
");
612. printf("**** 5 删除某卡号信息 ****** 6 增加新的用户 ****
");
613. printf("**************************************************
");
614. printf("**** 7 按余额降序输出 ****** 8 输出 ****
");
615. printf("**************************************************
");
616. printf("**** 0 退出 ****** 谢谢光临 ****
");
617. printf("**************************************************
");
618. printf("请选择您需要的业务
");
619. }
620.
621.
622.
623. //后台运行创建链表函数
624.
625. void chuangjian(struct person **Phead) //*(*Phead)为指向结构体指针的地址
626. {
627. struct person *p,*t; //定义操作指针
628. char n[20];
629. char a[20];
630. int s;
631. if(*Phead) *Phead=NULL;
632. printf("请输入卡号 姓名 余额 (若要结束请输入三个为零)
");
633. printf("请输入卡号
");
634. scanf("%s",n);
635. printf("请输入姓名
");
636. scanf("%s",a);
637. printf("请输入预存金额
");
638. scanf("%d",&s);
639. if(s==0) return;
640. p=(L *)malloc(sizeof(L)); //将信息输入链表中
641. strcpy(p->kehu.ID,n);
642. strcpy(p->kehu.name,a);
643. *Phead=p; //将指针重新指向头指针
644. printf("请输入卡号
");
645. scanf("%s",n);
646. printf("请输入姓名
");
647. scanf("%s",a);
648. printf("请输入预存金额
");
649. scanf("%d",&s);
650. while(s)
651. {
652. t=p; //将p的值赋给t,p又可以储存下一个结点
653. p=(L *)malloc(sizeof(L)); //为新结点开辟新的内存
654. strcpy(p->kehu.ID,n);
655. strcpy(p->kehu.name,a);
656. p->kehu.money=s;
657. p->next=NULL;
658. t->next=p; //将p的值接在t(即上一个结点的后面)
659. printf("请输入卡号
"); //尾插法
660. scanf("%s",n);
661. printf("请输入姓名
");
662. scanf("%s",a);
663. printf("请输入预存金额
");
664. scanf("%d",&s);
665. }
666. }
667.
668.
669.
670. //后台运行输出链表函数
671. /
672. void shuchu(struct person *Phead)
673. {
674. printf("
");
675. if(NULL==Phead)
676. {
677. printf("没有客户信息可输出!
"); //若头指针指向空,则没有客户信息
678. return;
679. }
680. while(Phead) //遍历输出链表中所有客户信息
681. {
682. printf("卡号:%s
姓名:
余额:%d
",Phead->kehu.ID,Phead->kehu.name,Phead->kehu.money);
683. Phead=Phead->next;
684. }
685. printf("
");
686. }
687.
688.
689. //后台运行卡号查询函数
690. ///
691.
692. void chaxun1(struct person*Phead)
693. {
694. char m[20]; //定义输入查找客户卡号的变量
695. if(NULL==Phead) //若头指针向空,则没有客户信息
696. {
697. printf("没有客户信息可查询!
");
698. return;
699. }
700. printf("请输入要查询的客户卡号:
");
701. scanf("%s",m);
702. while(NULL!=Phead&&strcmp(Phead->kehu.ID,m)!=0) //在链表中遍历寻找中,直到链表存在并且卡号核对无误
703. Phead=Phead->next;
704. if(Phead==NULL) //若指针指最后指向空,则没有客户信息
705. printf("对不起,没有该用户!
");
706. else
707. printf("卡号:%s
姓名:
余额:%d
",Phead->kehu.ID,Phead->kehu.name,Phead->kehu.money);
708.
709. } //若找到,则输出客户信息
710.
711.
712.
713. //后台运行姓名查询函数
714. /
715.
716.
717.
718. void chaxun2(struct person *Phead)
719. {
720. char m[20]; //定义输入查找客户卡号的变量
721. if(NULL==Phead) //若头指针向空,则没有客户信息
722. {
723. printf("没有客户信息可查询!
");
724. return;
725. }
726. printf("请输入要查询的客户姓名:
");
727. scanf("%s",m);
728. while(NULL!=Phead&&strcmp(Phead->kehu.name,m)!=0) //在链表中遍历寻找中,直到链表存在并且姓名核对无误
729. Phead=Phead->next;
730. if(Phead==NULL) //若指针指最后指向空,则没有客户信息
731. printf("对不起,没有该用户!
");
732. else
733. printf("卡号:%s
姓名:
余额:%d
",Phead->kehu.ID,Phead->kehu.name,Phead->kehu.money);
734.
735. } //若找到,则输出客户信息
736.
737.
738. //后台运行余额查询函数
739. /
740.
741. void chaxun3(struct person *Phead)
742. {
743. long x; //定义输入查找客户余额的变量
744. if(NULL==Phead) //若头指针向空,则没有客户信息
745. {
746. printf("没有客户信息可查询!
");
747. return;
748. }
749. printf("请输入要查询的客户信息的余额:
");
750. scanf("%ld",&x);
751. while(NULL!=Phead&&Phead->kehu.money!=x) //在链表中遍历寻找中,直到链表存在并且余额核对无误,继续寻找
752. Phead=Phead->next;
753. if(Phead==NULL) //若指针指最后指向空,则没有客户信息
754. printf("对不起,没有该用户!
");
755. else
756. printf("该客户的信息为
");
757. printf("卡号:%s
姓名:
余额:%d
",Phead->kehu.ID,Phead->kehu.name,Phead->kehu.money);
758.
759. } //若找到,则输出客户信息
760.
761.
762. //后台运行删除客户信息函数
763. ///
764. void shanchu(struct person **Phead) //*(*Phead)为指向结构体指针的地址
765. {
766. char k[20]; //定义输入查找客户姓名卡号的变量
767. struct person *p=*Phead,*t;
768. if(NULL==(*Phead)) //若指针最后指向空,则没有客户信息
769. {
770. printf("没有客户信息可删除!
");
771. return;
772. }
773. printf("请输入要删除的客户卡号:
");
774. scanf("%s",k);
775. if(p->kehu.ID==k) //若第一个客户就是,则让头指针指向下一个结点
776. *Phead=(*Phead)->next,free(p);
777. else
778. {
779. while(NULL==p->next&&p->next->kehu.ID!=k) //遍历寻找,核对客户卡号
780. p=p->next; //当p->next没指向空,并且客户的卡号还没找到,则继续寻找
781. if(p->next==NULL)
782. printf("对不起,没有该客户!
");
783. else
784. {
785. t=p->next; //如果找到,则把p->next的值赋给t
786. p->next=p->next->next;
787. }
788. }
789. }
790.
791. //后台运行增加用户信息函数
792.
793. void zengjia(struct person **Phead) //*(*Phead) 为指向结构体指针的地址
794. {
795. char n[20]; //定义输入增加客户卡号的变量
796. char a[20]; //定义输入增加客户姓名的变量
797. int s;
798. L *p,*t,*k; //定义操作指针变量
799. printf("请输入要插入的客户信息
");
800. printf("请输入卡号
"); //尾插法
801. scanf("%s",&n);
802. printf("请输入姓名
");
803. scanf("%s",a);
804. printf("请输入预存金额
");
805. scanf("%d",&s);
806. p=(L *)malloc(sizeof(L)); //开辟空间
807. strcpy(p->kehu.ID,a); //将新的客户信息写入链表
808. p->kehu.money=s;
809. strcpy(p->kehu.name,n);
810. if(NULL==(*Phead)) //如果是空链表,则把新客户信息作为第一个结点
811. {
812. *Phead=p; //头插法
813. (*Phead)->next=NULL;
814. return ;
815. }
816. else
817. {
818. p->next=(*Phead); //头插法
819. (*Phead)=p;
820. }
821. }
三.个人小结
1)在软件开发中,掌握时间是一个很重要的技能,请通过psp表格做到:
a.理清开发的完整环节,争取在每个环节都有实际的工作,一开始边界不清楚是正常的,但请尝试按照自己的理解努力对应每个环节的实际工作
b.预估每个环节的时间,并真实统计这些环节的耗时,在完成后填写完整的psp耗时表
c.这些表格是给自己看的,请不要伪造数据
psp2.1 | 任务内容 | 计划需要完成的时间(min | 实际完成需要的时间(min) |
---|---|---|---|
Planning | 计划 | 300 | 360 |
Estimate | 估计这个任务需要多少时间,并规划大致工作步骤 | 360 | 360 |
Development | 开发 | 20 | 15 |
Analysis | 需求分析(包括学习新技术) | 30 | 30 |
Design Spec | 生成设计文档 | 40 | 30 |
Design Review | 设计复审 | 30 | 30 |
Coding Standard | 代码规范 | 20 | 15 |
Design | 具体设计 | 20 | 10 |
Coding | 具体编码 | 100 | 120 |
Code Review | 代码复审 | 10 | 20 |
Test | 测试(自我测试,修改代码,提交修改) | 10 | 15 |
Reporting | 报告 | 20 | 20 |
Test Report | 测试报告 | 20 | 15 |
Size Measurement | 计算工作量 | 20 | 10 |
Postmortem & Process Improvement Plan | 事后总结,并提出过程改进计划 | 20 | 20 |