该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
window(15,2,78,23);
textbackground(LIGHTGREEN);
textcolor(LIGHTMAGENTA);
clrscr();
gotoxy(1,3);
printf("Delete name:");
cnt=rtnstr(str,2,13);str[13]='\0';
if(cnt==0)
{clrscr();return n;}
for(i=0;i
{ num++; window(16,5,78,7);
clrscr();
gotoxy(4,5);
printf("%-2d %-14s %-15s %-15s %-15s",i,psn[i].name,psn[i].tel,psn[i].eml,psn[i].dpmnt);
if(num==1)indx=i;
}
if(num==1){ gotoxy(1,8);
printf("Find 1 recod. Delete it(Y/N)?:");
do
{ ch=getch();
if(ch=='Y'||ch=='y')
{ clrscr();
window(16,10,78,12);
clrscr();
gotoxy(1,10);
printf(" Deleted a record! name: %s",str);
for(i=indx;i
savstate=0;n--;
return n;
}
else if(ch=='N'||ch=='n')
{clrscr();
return n;
}
}while(1);
if(num>1)
{ printf("\n\nFind %d recods.Input the number before a record to delete it:\n\n",num);
cnt=rtnstr(str,1,3);
if(cnt==0)
{clrscr();return n;}
cnt=strlen(str);
if(cnt==3)
{clrscr();
printf(" Index error!");
return n;
} /*借用cnt(continue)*/
if(cnt==1) cnt=str[0]-48; /*续借,indx还要用到*/
else if(cnt==2) cnt=(str[0]-48)*10+str[1]-48;
if(cnt
{ clrscr();
printf(" Deleted a record! name: %s",psn[indx].name);
for(i=cnt;i
savstate=0;n--;
return n;
}
else
{ clrscr();
printf(" Index error!"); return n;}
}
clrscr();
printf(" The name %s do not exist!",str);
return n;
}
}
void e_update() /*修改记录 。姓名重复输入序号字符串再转化为整数,由于情况简单直接讨论*/
{ int i,indx,num=0,cnt=1; char str[14]; struct person temp;
window(3,2,78,23);
textbackground(LIGHTGREEN);
textcolor(LIGHTMAGENTA);
clrscr();
gotoxy(1,2);
printf("Please input the friend's name:");
cnt=rtnstr(str,2,13);
str[13]='\0';
if(cnt==0)
{clrscr();return;}
for(i=0;i
if(strcmp(psn[i].name,str)==0)
{ num++; gotoxy(1,4);
printf("%-2d %-14s %-15s %-15s %-15s",i,psn[i].name,psn[i].tel,psn[i].eml,psn[i].dpmnt);
if(num==1)indx=i;
}
if(num==1)
{ temp=psn[indx];
gotoxy(1,6);
printf("Please input new information,Esc back to menu:");
gotoxy(1,8);
printf("name:");
cnt=rtnstr(psn[indx].name,2,13);
if(cnt==0)
{psn[indx]=temp;clrscr();return;}
gotoxy(1,10);
printf("phonenumber:");
cnt=rtnstr(psn[indx].tel,7,12);
if(cnt==0)
{psn[indx]=temp;clrscr();return;}
gotoxy(1,12);
printf("email:");
cnt=rtnstr(psn[indx].eml,7,21);
if(cnt==0){psn[indx]=temp;clrscr();return;}