|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
为什么直接不进行输入,直接跳过,第31行
- #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):");
- 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):");
- 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;
- }
复制代码
- #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;
- }
复制代码
|
-
-
|