資源簡介
活期儲蓄處理中,儲戶開戶、銷戶、存入、支出活動頻繁,系統設計要求:
能比較迅速地找到儲戶的帳戶,以實現存款、取款記賬;
能比較簡單,迅速地實現插入和刪除,以實現開戶和銷戶的需要。

代碼片段和文件信息
#include
#include
#include
struct?link?*kaihu(struct?link?*head);
struct?link??*xiaohu(struct?link?*head);
?
chakan(struct?link?*head);
cunkuan?(struct?link?*head);
qukuan(struct?link?*head);
struct?link
{????
int?id;
char?name[10];
int?num;
????struct?link?*next;
};
main()
{
???int?i;
???char?c;
???struct?link?*head=NULL;
???printf(“是否需要辦理業務(y/n)“);
???scanf(“%c“&c);
???while(c==‘y‘)
????{
?? ?????printf(“請選擇需要的業務?1?開戶??2??銷戶??3??存款??4??取款??5??查詢“);
?????????scanf(“?%d“&i);
?????????switch(i)
?????????{
????? ????case?1:
??????????????head=kaihu(head);
??????????????break;
????????????case?2:
???? ??????head=xiaohu(head);
???? ??????break;
????????????case?3:
???? ??????qukuan(head);
???? ??????break;
????????????case?4:
???? ??????cunkuan(head);
???? ??????break;
case?5:
??chakan(head);
??break;
????????????default:
???? ? ??printf(“命令非法“);
??????????}
?????????printf(“是否需要繼續辦理其它業務(y/n)\n“);
??????? scanf(“?%c“&c);
???}
?}
struct?link?*kaihu(struct?link?*head)
{
??struct?link?*p=NULL;
??struct?link?*pr=head;
??int?id?;
??char?name[10];
??int?num;
???
??p=(struct?link?*)malloc(sizeof(struct?link));
??if(p==NULL)
???{
?????printf(“?error“);
?????exit(0);
???}
???if(head==NULL)
???{
?????head=p;
???}
???else
???{
??????while(pr->next!=NULL)
??????{
????????pr=pr->next;
??????}
??????pr->next=p;
???}
???pr=p;
??
???printf(“?請輸入儲戶編號\n“);
???scanf(“%d“&id);???
???pr->id=id;?
???printf(“請輸入儲戶姓名\n“);
???scanf(“%s“pr->name);
???printf(“請輸入金額\n“);
???scanf(“%d“&num);
???pr->num=num;
???pr->next=NULL;
???return?head;
}
struct?link?*xiaohu(struct?link?*head)
{
int?j;
struct?link?*p=head*pr=head;
????printf(“請輸入賬戶id\n“);
????scanf(“%d“&j);
????if(head==NULL)
{
printf(“error“);
}?
????while(j!=p->id&&p->next!=NULL)
?{
????pr=p;
????p=p->next;
?}
if(j==p->id)
?{
???if(p==head)
? ??{
? ??? ??head=p->next;
? ??}
???else
? ??{
? ??? ?pr->next=p->next;
??????}
???free(p);
?}
???else
??? {
??? printf(“無此賬戶“);
??? }
??return?head;
}
qukuan(struct?link?*head)
{
int?mn;
struct?link?*p=head*pr=head;
????if(head==NULL)
?? {
?? ???printf(“error“);
??? }
????printf(“請輸入賬戶id“);
????scanf(“%d“&m);
????printf(“請輸入存款金額“);
????scanf(“%d“&n);
????while(m!=p->id&&p->next!=NULL)
{
??????pr=p;
??????p=p->next;
}
???if(m==p->id)
??? {
??? ??p->num=p->num+n;
??? }
???
}
cunkuan?(struct?link?*head)
{
int?mn;
struct?link?*p=head*pr=head;
????if(head==NULL)
?? {
?? ???printf(“error“);
??? }
???printf(“請輸入賬戶id:“);
???scanf(“%d“&m);
???printf(“請輸入取款金額“);
???scanf(“%d“&n);
???while(m!=p->id&&p->next!=NULL)
???{
??????pr=p;p=p->next;
???}
???if(m==p->id)
??? {
???
??? ??if(p->num ??? ?? {
??? ?? ???printf(“余額不足\n“);
??? ?? }
??? ??else
??? ?? {
??? ?? ?p->num=p->num-n;
??? ?? }
??? }
???
}
?cha
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????184389??2009-05-11?21:19??test.exe
?????文件???????3461??2009-05-11?21:19??test.c
-----------?---------??----------?-----??----
???????????????187850????????????????????2
評論
共有 條評論