跪求!哪位C语言高手帮忙编下下面的程序, 麻烦把程序发到799792271@qq.com这个邮箱里。谢谢

2025-02-24 04:01:40
推荐回答(3个)
回答1:

/*
* main.c
*
* Created on: 2011-6-6
* Author: icelights
*/

#include
#include
#include
#include

#define TotalStu 5 /*学生总数Total student*/

struct Database
{

/*学号Student No.*/
char sn[80];

/*笔试成绩Written test score*/
double wts;

/*理论课综合训练成绩扣分
*Comprehensive training course grades possessed*/
double ctcgp;

/*机考成绩Machine examination results*/
double mer;

/*上机扣分Computer possessed*/
double cp;

/*总成绩Total score*/
double ts;

/*挂科与否Hanged division */
int hd;

};

/*输出文件*/
void output(struct Database Stu[])
{
FILE *fp;

int liv_cnt;
if((fp=fopen("d:\\StuDBA.txt","wt+"))== NULL)
{
puts("Couldn't read the file\n");

}

rewind(fp);

for(liv_cnt = 0; liv_cnt < TotalStu; liv_cnt++)
{
fprintf(fp,"%s %lf %d\n" , Stu[liv_cnt].sn,
Stu[liv_cnt].ts, Stu[liv_cnt].hd);
}

if(fclose(fp))
{
puts("Fail to close the file.\n");

}

}

/*计算成绩&判断挂科*/
void cal(struct Database Stu[])
{

int liv_cnt;
for (liv_cnt = 0; liv_cnt < TotalStu; liv_cnt++)
{
Stu[liv_cnt].ts = (Stu[liv_cnt].wts - Stu[liv_cnt].ctcgp) * 0.6
+ (Stu[liv_cnt].mer - Stu[liv_cnt].cp) * 0.4;
printf("%s%lf%lf%lf%lf",
Stu[liv_cnt].sn, Stu[liv_cnt].wts, Stu[liv_cnt].ctcgp,
Stu[liv_cnt].mer, Stu[liv_cnt].cp);
if (Stu[liv_cnt].ts < 60)
{
Stu[liv_cnt].hd = 0;
}
else
{
Stu[liv_cnt].hd = 1;
}

}

output(Stu);
}
/*接受用户输入*/
void input(void)
{
struct Database Stu[TotalStu];
int liv_cnt;
puts("Please enter the Student No. Written test score");
puts("Comprehensive training course grades possessed");
puts("Machine examination results and Computer possessed");

for (liv_cnt = 0; liv_cnt < TotalStu; liv_cnt++)
{
scanf("%s%lf%lf%lf%lf",
Stu[liv_cnt].sn, &Stu[liv_cnt].wts, &Stu[liv_cnt].ctcgp,
&Stu[liv_cnt].mer, &Stu[liv_cnt].cp);

}/*end of for (liv_cnt = 0; liv_cnt < TotalStu; liv_cnt++)*/

cal(Stu);
}
/*主函数*/
int main(void)
{
input();
return 0;
}

回答2:

理论课综合训练成绩扣分0~20,怎么没有输入?
#include
void main()
{
int i;
int sum[i];

typedef struct stu
{
int NO;
int pen;
int integrate;
int robot;
int surf;
}S;

S stu[5];

for(int i=0;i<5;i++)
{
printf("输入学号,笔试成绩,理论课综合训练成绩扣分,机考成绩,上机扣分\n");
scanf("%d %d %d %d %d",&stu[i].NO,&stu[i].pen,&stu[i].integrate,&stu[i].robot,&stu[i].surf);

sum[i]=(stu[i].pen-stu[i].integrate)*(6/10)+(stu[i].robot-stu[i].surf)*(4/10);
if(sum[i]<60)
{
printf("该学员挂科\n");
}
}

for(int i=0;i<5;i++)
{
for(int j=0;j<5-i;j++)
{
if(sum[j]>sum[j+1])
{
int temp;
temp=sum[j];
sum[j]=sum[j+1];
sum[j+1]=temp;
}
}
}
for(int i=0;i<5;i++)
{
printf("%d ",sum[i]);

}
}

回答3:

盘文件输入
并盘文件输出,
输入输出都没讲清楚。。。