Example #1
0
void DeleteRecord(CList&TelList)
{
 CNode *pLook;
 char szName[20];
        cout<<"请输入您需要删除的姓名(输入0退出,并进入系统菜单)"<<endl;
 cin.getline(szName,20);
 while(strcmp(szName,"0"))
 {
  CTelRecord tel(szName,"0");
  pLook=TelList.LookUp(tel);
  if (pLook)
  {
   cout<<"在电话簿中找到"<<szName<<",内容是:"<<endl;
               pLook->ShowNode();
   cout<<"请确定是否删除此记录(Y/N)【确定删除请输入Y或y,取消删除请输入N或n】:"<<endl;
   char ok;
   cin>>ok;
                        cin.ignore();
   if (ok=='Y'||ok=='y')
   {
       TelList.DeleteNode(pLook);
       cout<<szName<<"的资料删除成功!"<<endl;
       delete pLook;
       count--;
   }
   else if(ok=='N'||ok=='n')
    cout<<szName<<"的资料删除失败"<<endl;
  }
  else
    cout<<"在电话簿中找不到"<<szName<<","<<endl;
  cout<<"请输入您需要删除的姓名(输入0退出,并进入系统菜单)"<<endl;
        cin.getline(szName,20);
 }
Example #2
0
void LookUpRecord(CList&TelList)
{
 CNode *pLook;
 char szName[20];
 cout<<"请输入您需要查找的姓名(输入0退出,并进入系统菜单)"<<endl;
 cin.getline(szName,20);
 while (strcmp(szName,"0"))
 {
  CTelRecord tele(szName,"0");
  pLook=TelList.LookUp(tele);
  if (pLook)
  {
   cout<<"在电话簿中找到"<<szName<<",内容是:"<<endl;
            cout<<setw(15)<<"【姓名】"<<setw(15)<<"【电话号码】"<<endl;
   pLook->ShowNode();
  }
  else 
   cout<<"在电话簿中找不到"<<szName<<","<<endl;
  cout<<"请输入您需要查找的姓名(输入0退出,并进入系统菜单)"<<endl;
  cin.getline(szName,20);
 }
 cout<<endl<<endl;
}