c语言作业-------------------------------------------------
从键盘输入一个同学的学号及高数、英语、C语言3门课的成绩,计算平均分,并写入文件score_avg.txt中。(刚学不怎么会,希望能完整的写一个范本。谢谢)...
从键盘输入一个同学的学号及高数、英语、C语言3门课的成绩,计算平均分,并写入文件score_avg.txt中。(刚学不怎么会,希望能完整的写一个范本。谢谢)
展开
1个回答
展开全部
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//
int main()
{
st:
FILE *fp;
int a = 0, b = 0, c = 0;
int sabc = 0;
char abc[10] = "123456789";
printf("%s\n", "请输入3个整数,每输入完1个整数 按 Enter 键");
scanf("%d %d %d", &a, &b, &c);
printf("a+b+c/3=%d\n", (a+b+c)/3);
sabc = (a+b+c)/3;
if(a+b+c<=3){goto st;}
itoa(sabc, abc, 10);
if((fp = fopen("score_avg.txt","w+")) == NULL )
{
printf("No");
}else{
fwrite(&abc, strlen(abc), 1, fp);
fclose(fp);
printf("%s\n", "OK");
}
}
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//
int main()
{
st:
FILE *fp;
int a = 0, b = 0, c = 0;
int sabc = 0;
char abc[10] = "123456789";
printf("%s\n", "请输入3个整数,每输入完1个整数 按 Enter 键");
scanf("%d %d %d", &a, &b, &c);
printf("a+b+c/3=%d\n", (a+b+c)/3);
sabc = (a+b+c)/3;
if(a+b+c<=3){goto st;}
itoa(sabc, abc, 10);
if((fp = fopen("score_avg.txt","w+")) == NULL )
{
printf("No");
}else{
fwrite(&abc, strlen(abc), 1, fp);
fclose(fp);
printf("%s\n", "OK");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |