c语言求纠错得到正确结果,困扰一个晚上了
#include<stdio.h>#include<stdlib.h>#include<string.h>structinfo{charname[12];chartime...
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct info
{
char name[12];
char time[10];
char date[11];
char answer[11];
char lang[5];
char question[5];
char memory[10];
char number[6];
char costtime[10];
char length[7];
};
int judge(struct info* m,struct info* n);
#define FORMAT &p[i].number,&p[i].name,&p[i].question,&p[i].answer,&p[i].memory,&p[i].costtime,&p[i].lang,&p[i].length,&p[i].date,&p[i].time
int main()
{
int t,i=0,j; //j为有多少组数据,通过循环来完成
scanf("%d",&t);
struct info *p=0;
p=(struct info*)malloc(2*t*sizeof(struct info));
while(i<(2*t))
{
scanf("%s%s%s%s%s%s%s%s",FORMAT);
i++;
}
for(i=0;i<(2*t);i=i+2)
{
judge(p+i,p+(i+1));
}
free(p);
p=0;
}
int judge(struct info* m,struct info* n)
{
int k=1;
if(strcmp(m->question,n->question)!=0)k=0;
if(strcmp(m->answer,n->answer)!=0)k=0;
if(strcmp(m->memory,n->memory)!=0)k=0;
if(strcmp(m->costtime,n->costtime)!=0)k=0;
if(strcmp(m->length,n->length)!=0)k=0;
if(strcmp(m->lang,n->lang)!=0)k=0;
if(k==0)printf("%s might have not copied the code of %s.",m->name,n->name);
else printf("%s might have copied the code of %s.",m->name,n->name);
}
求解释 展开
#include<stdlib.h>
#include<string.h>
struct info
{
char name[12];
char time[10];
char date[11];
char answer[11];
char lang[5];
char question[5];
char memory[10];
char number[6];
char costtime[10];
char length[7];
};
int judge(struct info* m,struct info* n);
#define FORMAT &p[i].number,&p[i].name,&p[i].question,&p[i].answer,&p[i].memory,&p[i].costtime,&p[i].lang,&p[i].length,&p[i].date,&p[i].time
int main()
{
int t,i=0,j; //j为有多少组数据,通过循环来完成
scanf("%d",&t);
struct info *p=0;
p=(struct info*)malloc(2*t*sizeof(struct info));
while(i<(2*t))
{
scanf("%s%s%s%s%s%s%s%s",FORMAT);
i++;
}
for(i=0;i<(2*t);i=i+2)
{
judge(p+i,p+(i+1));
}
free(p);
p=0;
}
int judge(struct info* m,struct info* n)
{
int k=1;
if(strcmp(m->question,n->question)!=0)k=0;
if(strcmp(m->answer,n->answer)!=0)k=0;
if(strcmp(m->memory,n->memory)!=0)k=0;
if(strcmp(m->costtime,n->costtime)!=0)k=0;
if(strcmp(m->length,n->length)!=0)k=0;
if(strcmp(m->lang,n->lang)!=0)k=0;
if(k==0)printf("%s might have not copied the code of %s.",m->name,n->name);
else printf("%s might have copied the code of %s.",m->name,n->name);
}
求解释 展开
展开全部
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct info
{
char name[12];
char time[10];
char date[11];
char answer[11];
char lang[5];
char question[5];
char memory[10];
char number[6];
char costtime[10];
char length[7];};
judge(struct info* m,struct info* n);
#define FORMAT p[i].number,p[i].name,p[i].question,p[i].answer,p[i].memory,p[i].costtime,p[i].lang,p[i].length,p[i].date,p[i].time
main()
{
int t,i=0,j; //j为有多少组数据,通过循环来完成scanf("%d",&t);
struct info *p;
scanf("%d",&t);
p=(struct info*)malloc(2*t*sizeof(struct info));
while(i<(2*t))
{scanf("%s%s%s%s%s%s%s%s",FORMAT);i++; }
for(i=0;i<(2*t);i=i+2)
{
judge(p+i,p+(i+1));}
free(p);
}
judge(struct info* m,struct info* n)
{
int k=1;
if(strcmp(m->question,n->question)!=0)k=0;
if(strcmp(m->answer,n->answer)!=0)k=0;
if(strcmp(m->memory,n->memory)!=0)k=0;
if(strcmp(m->costtime,n->costtime)!=0)k=0;
if(strcmp(m->length,n->length)!=0)k=0;
if(strcmp(m->lang,n->lang)!=0)k=0;
if(k==0)printf("%s might have not copied the code of %s.\n",m->name,n->name);
else printf("%s might have copied the code of %s.\n",m->name,n->name);
}
楼主试试行不
#include<stdlib.h>
#include<string.h>
struct info
{
char name[12];
char time[10];
char date[11];
char answer[11];
char lang[5];
char question[5];
char memory[10];
char number[6];
char costtime[10];
char length[7];};
judge(struct info* m,struct info* n);
#define FORMAT p[i].number,p[i].name,p[i].question,p[i].answer,p[i].memory,p[i].costtime,p[i].lang,p[i].length,p[i].date,p[i].time
main()
{
int t,i=0,j; //j为有多少组数据,通过循环来完成scanf("%d",&t);
struct info *p;
scanf("%d",&t);
p=(struct info*)malloc(2*t*sizeof(struct info));
while(i<(2*t))
{scanf("%s%s%s%s%s%s%s%s",FORMAT);i++; }
for(i=0;i<(2*t);i=i+2)
{
judge(p+i,p+(i+1));}
free(p);
}
judge(struct info* m,struct info* n)
{
int k=1;
if(strcmp(m->question,n->question)!=0)k=0;
if(strcmp(m->answer,n->answer)!=0)k=0;
if(strcmp(m->memory,n->memory)!=0)k=0;
if(strcmp(m->costtime,n->costtime)!=0)k=0;
if(strcmp(m->length,n->length)!=0)k=0;
if(strcmp(m->lang,n->lang)!=0)k=0;
if(k==0)printf("%s might have not copied the code of %s.\n",m->name,n->name);
else printf("%s might have copied the code of %s.\n",m->name,n->name);
}
楼主试试行不
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#define FORMAT &p[i].number,&p[i].name,&p[i].question,&p[i].answer,&p[i].memory,&p[i].costtime,&p[i].lang,&p[i].length,&p[i].date,&p[i].time
每个都去掉 &
scanf("%s%s%s%s%s%s%s%s",FORMAT);
改为10个%s
scanf("%s%s%s%s%s%s%s%s%s%s",FORMAT);
每个都去掉 &
scanf("%s%s%s%s%s%s%s%s",FORMAT);
改为10个%s
scanf("%s%s%s%s%s%s%s%s%s%s",FORMAT);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询