简单的同学通讯录问题 望改正~
#include<stdio.h>#include<string.h>
typedef struct classmate
{
char name[10];
char phone[15];
}CM;
void main()
{
int n,NUM;
printf("输入学生人数n=");
scanf("%d",&n);
NUM=n;
CM a[NUM];
char name[10],ch='y';int i;
getchar();
for(i=0;i<NUM;i++)
{
printf("input NO.%d name:",i+1);
gets(a[i].name);
printf("input phone:\n");
gets(a[i].phone);
}
while(ch=='y'||ch=='Y')
{
printf("输入要查找人姓名:");
gets(name);
for(i=0;i<NUM;i++)
if(strcmp(name,a[i].name)==0)
{
printf("%s's phone number is:%s\n",a[i].name,a[i].phone);
break;
}
if(i==NUM)
printf("can't find!");
printf("continue?(y/n):");
ch=getchar();
getchar();
}
}
望改正啊