帮忙写一下C语言课作业,写一个简单的程序,CB好商量

查看 75|回复 9
作者:Supermexyh   
前排提示:不要对我进行人身攻击,这门课是每个专业的人都需要选,非计算机专业也需要选,并且是必修的
[color=]程序需要实现十个功能,这是作业文档下载地址:https://wwwo.lanzoum.com/i0hmG0x3cvsd,具体的要求在文档里面,难度不高,希望各位C语言大佬可以出手帮忙做一下,谢谢了,CB不够可以加
(这个东西网上好像有类似甚至一样的,也许你们可以去看看)
下面这张图片是需要实现的功能,建议把文档下载下来看

微软, 作业

ialove   

工资怎么 不发出来让大家领呢
西门市场   

[C] 纯文本查看 复制代码#include
#include
#include
//定义结构体类型描述学生信息
typedef struct student {
    int number; //学号
    char name[20]; //姓名
    int score[6]; //各科成绩
    int total; //总成绩
    double average; //平均成绩
} student;
//定义全局变量存储学生人数和课程门数
int n, m;
//定义函数原型
void input_record(student *stu); //录入每个学生的学号、姓名和各科考试成绩
void caculate_course(student *stu, int *course_total, double *course_average); //计算每门课程的总分和平均分
void caculate_student(student *stu); //计算每个学生的总分和平均分
void sort_by_total(student *stu); //按每个学生的总分由高到低排出名次表
void sort_by_number(student *stu); //按学号由小到大排出成绩表
void sort_by_name(student *stu); //按姓名的字典顺序排出成绩表
void search_by_number(student *stu); //按学号查询学生的相关信息
void search_by_name(student *stu); //按姓名查询学生的相关信息
void statistic_analysis(student *stu, int (*stat)[5]); //按优秀(90~100)、良好(80~90)、中等(70~80)、及格(60~70)、不及格(0~59)5个类别,对每门课程分别统计每个类别的人数以及所占的百分比
void list_record(student *stu, int *course_total, double *course_average); //输出每个学生的学号、姓名、各科考试成绩以及每门课程的总分和平均分
//主函数
int main() {
    student stu[30]; //定义结构体数组存储学生信息
    int course_total[6] = {0}; //定义数组存储每门课程的总分
    double course_average[6] = {0.0}; //定义数组存储每门课程的平均分
    int stat[6][5] = {0}; //定义二维数组存储每门课程的统计结果
    printf("Please input the number of students (no more than 30): ");
    scanf("%d", &n); //输入学生人数
    printf("Please input the number of courses (no more than 6): ");
    scanf("%d", &m); //输入课程门数
    int choice; //定义变量存储用户选择的选项
    do {
        printf("\n1. Input record\n"); //显示菜单并提示用户输入选项
        printf("2. Caculate total and average score of every course\n");
        printf("3. Caculate total and average score of every student\n");
        printf("4. Sort in descending order by total score of every student\n");
        printf("5. Sort in ascending order by number\n");
        printf("6. Sort in dictionary order by name\n");
        printf("7. Search by number\n");
        printf("8. Search by name\n");
        printf("9. Statistic analysis for every course\n");
        printf("10. List record\n");
        printf("0. Exit\n");
        printf("Please input your choice: ");
        scanf("%d", &choice);
        switch(choice) { //根据用户选择执行相应的功能函数
            case 1:
                input_record(stu);
                break;
            case 2:
                caculate_course(stu, course_total, course_average);
                break;
            case 3:
                caculate_student(stu);
                break;
            case 4:
                sort_by_total(stu);
                break;
            case 5:
                sort_by_number(stu);
                break;
            case 6:
                sort_by_name(stu);
                break;
            case 7:
                search_by_number(stu);
                break;
            case 8:
                search_by_name(stu);
                break;
            case 9:
                statistic_analysis(stu, stat);
                break;
            case 10:
                list_record(stu, course_total, course_average);
                break;
            case 0:
                exit(0); //退出程序
            default:
                printf("Invalid choice!\n"); //无效选项提示
        }
    } while(choice != 0);
    return 0;
}
//录入每个学生的学号、姓名和各科考试成绩函数实现
void input_record(student *stu) {
    for(int i = 0; i  100) { //判断成绩是否合法,如果不合法则重新输入
                printf("Invalid score! Please input again: ");
                scanf("%d", &stu[i].score[j]);
            }
        }
    }
}
//计算每门课程的总分和平均分函数实现
void caculate_course(student *stu, int *course_total, double *course_average) {
    for(int i = 0; i = 0 && strcmp(stu[j].name, temp.name) > 0) { //循环比较待插入位置的元素与待插入元素的姓名,如果待插入位置的元素的姓名大于待插入元素的姓名,说明需要后移一位,为待插入元素腾出空间。
            stu[j + 1] = stu[j]; //将待插入位置的元素后移一位
            j--; //将待插入位置的下标减一,继续向前比较
        }
        stu[j + 1] = temp; //将待插入元素放到最终的待插入位置上
    }
    printf("\nThe rank list by name is:\n"); //输出按姓名排序后的成绩表
    printf("Number\tName\tScore1\tScore2\tScore3\tScore4\tScore5\tScore6\tTotal\tAverage\n");
    for(int i = 0; i = 90) { //如果该学生该门课程的成绩在90~100之间,说明属于优秀类别
                stat[i][0]++; //将该门课程的优秀类别的人数加一
            } else if(stu[j].score[i] >= 80) { //如果该学生该门课程的成绩在80~90之间,说明属于良好类别
                stat[i][1]++; //将该门课程的良好类别的人数加一
            } else if(stu[j].score[i] >= 70) { //如果该学生该门课程的成绩在70~80之间,说明属于中等类别
                stat[i][2]++; //将该门课程的中等类别的人数加一
            } else if(stu[j].score[i] >= 60) { //如果该学生该门课程的成绩在60~70之间,说明属于及格类别
                stat[i][3]++; //将该门课程的及格类别的人数加一
            } else { //如果该学生该门课程的成绩在0~59之间,说明属于不及格类别
                stat[i][4]++; //将该门课程的不及格类别的人数加一
            }
        }
        printf("\nThe statistic analysis of course %d is:\n", i + 1); //输出该门课程的统计结果
        printf("Excellent\tGood\tMedium\tPass\tFail\n");
        printf("%d\t\t%d\t%d\t%d\t%d\n", stat[i][0], stat[i][1], stat[i][2], stat[i][3], stat[i][4]); //输出每个类别的人数
        printf("%.2f%%\t\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\n", (double)stat[i][0] / n * 100, (double)stat[i][1] / n * 100, (double)stat[i][2] / n * 100, (double)stat[i][3] / n * 100, (double)stat[i][4] / n * 100); //输出每个类别所占的百分比,注意转换为浮点数除法和乘法
    }
}
//输出每个学生的学号、姓名、各科考试成绩以及每门课程的总分和平均分函数实现
void list_record(student *stu, int *course_total, double *course_average) {
    printf("\nThe list of every student's record is:\n"); //输出每个学生的相关信息
    printf("Number\tName\tScore1\tScore2\tScore3\tScore4\tScore5\tScore6\tTotal\tAverage\n");
    for(int i = 0; i
大概实现就是这样,代码都做了详细的中文注释,应该都能看得懂,还请麻烦验收一下。
Supermexyh
OP
  


ialove 发表于 2023-5-24 09:44
工资怎么 不发出来让大家领呢

。。。这是作业啊,你在想什么,真要工作老板可能要你写这么简单的东西吗,这一看就是练手的而已
Supermexyh
OP
  


西门市场 发表于 2023-5-24 10:04
[mw_shl_code=c,true]#include
#include
#include

谢谢了,我下午看一下
MiShu   

[C] 纯文本查看 复制代码#include
#include
#include
#define SN 30   //学生人数
#define CN 6    //科目数
#define NL 20   //名字字节长度
typedef struct student{
    long int num;
    char name[NL];
    float score[CN];
    float sum;
    float aver;
}STU;
STU s[SN];
int itemSelected=-1;
int n=0;//学生数
int m=0;//课程数
int Menu();//菜单
void chose(int itemSelected);//选择
void inputScore();//输入分数
void AverofC();//计算每门课程平均数
void AverofS();//每名学生总分和平均分
void sortByNum();//学生总分排行
void sortByGrade();
void sortByName();
void findByNum();
void findByName();
void statisticsAnalysis();
void printScore();
void main(){
    printf("Input student number (ns[i+1].num){
            temp1=s[i];
            s[i]=s[i+1];
            s[i+1]=temp1;
        }
    }
    printf("\n==============按学号从小到排序===============\n");
    for(int j=0;j(int)(s[i+1].name[0]))){
            //将名字首字母转成成ASCII码从而比较大小排序
            temp1=s[i];
            s[i]=s[i+1];
            s[i+1]=temp1;
        }
    }
    printf("\n==============按学号从小到排序===============\n");
    for(int j=0;j=90 && s[i].score[j]=80 && s[i].score[j]=70 && s[i].score[j]=60 && s[i].score[j]
ialove   

怪不得公司招的大学生,那么差水
Supermexyh
OP
  


西门市场 发表于 2023-5-24 10:04
[mw_shl_code=c,true]#include
#include
#include

有一点小问题,就是你的这个程序运行之后是先要求录入学生人数和课程门数才能显示菜单,可是要求是程序运行之后就直接显示菜单,然后输入1之后再录入学生人数和课程门数,请问你可以修改一下吗
Supermexyh
OP
  


ialove 发表于 2023-5-24 10:15
怪不得公司招的大学生,那么差水

我不是计算机专业的,和计算机什么关系都没有,但是现在每个专业都需要选计算机课。。。不然你以为我为什么会来问
Supermexyh
OP
  


MiShu 发表于 2023-5-24 10:13
[mw_shl_code=c,true]#include
#include
#include

谢谢,我等一下看看,第一位发的代码有点小问题
您需要登录后才可以回帖 登录 | 立即注册

返回顶部