?? infdelete.cpp
字號:
#include "include.h"
extern Inflinklist *head;
//------------------------------------------------
//--刪除信息
//------------------------------------------------
char Infindelete(Inflinklist * ps, char *name)
{
char cc;
int n=0; //通過n的值來判斷是否鏈表中有輸入的刪除姓名項
Inflinklist * q0, *q1, *del; //q0指向q1的前一位置,del用來標志姓名符合時的位置
q1=ps->next;
q0=ps;
if( q1 == NULL) //鏈表只有頭結點
printf("No information left in the linklist!\n");
else
{
while(q1!=NULL) //有同名時需比較到底
{
if(!( q1->name[0]==name[0])) //比較名字的第一個字符是否相同,不同則繼續
{ //節省比較時間
q0=q1;
q1=q1->next;
}
else
{
if(!(strcmp(q1->name, name))) //比較是否全部相同,相同則找到繼續往下
{
printf(" delete information is below:\n");
printf(" name:%s\t sex:%c\t age:%d\t spousename:%s\n",q1->name,q1->sex,q1->age,q1->spousename);
q0->next=q1->next;
del=q1; // 將位置賦與del,q1繼續向前
q1=q1->next;
free(del);
n=n+1;
}
else
{
q0=q1;
q1=q1->next;
}
}
}//end while
if(n==0) printf("No such name in the list! Be sure the name input is correct!\n");
}//end else
fflush(stdin);
printf("Dlete continue? press Y/y continue;to end,press N/n:\t");
cc= GetContinueNote();
return cc;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -