#include <stdio.h>
#include <stdlib.h>
struct Date
{
int n;
int y;
int r;
};
struct Record
{
char k[16];
int age;
struct Date a;
struct Date b;
};
void shur(struct Record *q[],int i)
{
char ch;
int j;
for(j=0;j<i;j++)
{
q[j]=(struct Record *)malloc(sizeof(struct Record));
}
for(j=0;j<i;j++)
{
printf("请输入姓名:");
scanf("%s",q[j]->k);
printf("请输入年龄:");
scanf("%d",&q[j]->age);
printf("是否打了第一针疫苗(y/n):");
fflush(stdin);/////////////////////////清除缓存,把'\n'消去,否则下面 scanf("%c",&ch);会接收'\n'
scanf("%c",&ch);
if(ch=='y')
{
scanf("%d-%d-%d",&q[j]->a.n,&q[j]->a.y,&q[j]->a.r);
}
else
{
continue;
}
printf("是否打了第二针疫苗(y/n):");
fflush(stdin);/////////////////////////清除缓存,把'\n'消去,否则下面 scanf("%c",&ch);会接收'\n'
scanf("%c",&ch);
if(ch=='y')
{
scanf("%d-%d-%d",&q[j]->b.n,&q[j]->b.y,&q[j]->b.r);
}
else
{
continue;
}
}
}
int main()
{
int i;
scanf("%d",&i);
struct Record *q[i];
shur(q,i);
return 0;
}
|