标签:scan else 中英文 简体 http print size 技术分享 fscanf
结对编程1 四则运算
201421122075 郭晓迪
201421122089 曾瑞
需求分析:
1、记录用户的对错总数,程序退出再启动的时候,能把以前的对错数量保存并在此基础上增量计算。
2、有计时功能,能显示用户开始答题后的消耗时间。
3、界面支持中文简体/英语,用户可以选择一种;
思维导图
1.选择语言
2.答题器
代码展示
中英文对比
char * edaanpanduan(char daan[],char * shuru,char * timu)
{
static char panduanjieguo[30];
FILE * in ,* out,* cuoti;
in=fopen("leijitimushu.txt","r");
fscanf(in,"%d,%d",&eright,&ewrong);
fclose(in);
if(strcmp(shuru,edaan)==0)
{
strcpy(panduanjieguo,"Right!");
eright++;
}
else
{
strcpy(panduanjieguo,"wrong!");
strcat(panduanjieguo,"Answer is:");
strcat(panduanjieguo,edaan);
ewrong++;
cuoti=fopen("cuotiji.txt","a");
fprintf(cuoti,"%s=%s wrong!Right answer is %s\n",timu,shuru,edaan);
fclose(cuoti);
}
out=fopen("leijitimushu.txt","w");
fprintf(out,"%d,%d",eright,ewrong);
fclose(out);
return panduanjieguo;
}
char * daanpanduan(char daan[],char * shuru,char *timu)
{
static char panduanjieguo[20];
FILE * in ,* out,* cuoti;
in=fopen("leijitimushu.txt","r");
fscanf(in,"%d,%d",&right,&wrong);
fclose(in);
if(strcmp(shuru,daan)==0)
{
strcpy(panduanjieguo,"回答正确!!!!");
right++;
}
else
{
strcpy(panduanjieguo,"错误!");
strcat(panduanjieguo,"正确答案为:");
strcat(panduanjieguo,daan);
wrong++;
cuoti=fopen("cuotiji.txt","a");
fprintf(cuoti,"%s=%s 错误!正确答案为%s\n",timu,shuru,daan);
fclose(cuoti);
}
out=fopen("leijitimushu.txt","w");
fprintf(out,"%d,%d",right,wrong);
fclose(out);
return panduanjieguo;
}
程序运行
小结感受
结对编程需要好好进行分工,从而才能好好团结协作,以1+1>2的效率完成工作。
评价伙伴
略。
PSP.
第三次作业 结对编程
标签:scan else 中英文 简体 http print size 技术分享 fscanf
原文地址:http://www.cnblogs.com/gxd8640/p/7712102.html