越来越晕了~T。T
人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
进展进展。有进展咯~虽然不太快~现在完成内存中的部分有添加,排列,查找。呼~如下。谁来测试测试玩。。。
不过输入比较累。。。。
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#define MAX 3
struct day
{
int month;
int day1;
};
struct mydata
{
char name[20];
struct day birthday;
char telnum[13];
};
main()
{
struct mydata a[MAX],t;
int i=0,j,g=0,flag; char ch,keyname[20];
printf("input the data:"); //输入data
do
{
printf("\ninput the name:");
gets(a[g].name);
printf("\ninput the birthday(mm-dd):");
scanf("%d-%d",&a[g].birthday.month,&a[g].birthday.day1);
getchar();
printf("\ninput the telphone number:");
gets(a[g].telnum);
printf("countuie?(press n or N to quie)");
scanf(" %c",&ch);
getchar();
}while((ch!=78)&&(ch!=110)&&(++g<MAX));
for(i=0;i<g-1;i++) //让人名从a-z排列
{
for(j=1;j<g;j++)
{
if(strcmp(a[i].name,a[j].name)>0)
{t=a[i];a[i]=a[j];a[j]=t;}
}
}
for(i=0;i<=g-1;i++) //输出所有人物!
{
printf("%s's birthday is %d.%d telphone number is %s.\n",
a[i].name,a[i].birthday.month,a[i].birthday.day1,a[i].telnum);
}
printf("input the search name:"); //查找人物!
gets(keyname);
for(i=0;i<=g-1;i++)
{
if(strcmp(keyname,a[i].name)!=0);
else
{
printf("Find the data:%s's birthday is %d.%d telphone number is %s.\n",
a[i].name,a[i].birthday.month,a[i].birthday.day1,a[i].telnum);
flag=0;
}
}
if(flag)printf("Can't find the data!!\n");
return 0;
}
[此贴子已经被作者于2006-6-27 15:25:24编辑过]