导航菜单
首页 >  » 正文

考研专业课成绩查询? 某学生的记录由学号、8门课程成绩和平均分组成,学号和8门课程的成绩已在主函数中给出。请编写函数fun,它的功能是:求出该学生的平均分放在记录的ave成员中。请自己定义正确的形参。

考研专业课成绩查询?

考试成绩一般是只能在学校的官网上面查询到的,其他地方查不到,在这里问更是不现实,最方便的做法还是直接打电话问班主任。

某学生的记录由学号、8门课程成绩和平均分组成,学号和8门课程的成绩已在主函数中给出。请编写函数fun,它的功能是:求出该学生的平均分放在记录的ave成员中。请自己定义正确的形参。

#include<stdio.h> #define N 8

struct stu_info{  int stu_id;  int score[N];  float ave;  };

float fun(struct stu_info stu) {  float aver = 0.0;  int i;  for(i = 0;i < N;i++)   aver += stu.score[i];  aver /= N;  return aver; }

int main() {  struct stu_info stu;  int i;  for(i = 0;i < N;i++)  {   stu.score[i] = random()%100;   printf("%4d",stu.score[i]);  }  stu.ave = fun(stu);  printf(" ave = %.2f ",stu.ave);  return 0; }

有一个班4个学生,5门课程.1、求第1门课程的平均分;2、找出有两门以上课程不及格的

#include<stdio.h>
int main()
{
float cour_aver(float (*p)[5],int cour);
int i,j;
float score[4][5];
for(i=0;i<4;i++)
{
printf("Please input 5 scores of student No.%d:",i+1);
for(j=0;j<5;j++)scanf("%f",&score[i][j]);}
printf(" Cour1 Cour2 Cour3 Cour4 Cour5 ");
for(i=0;i<4;i++)
{
printf("No.%d ",i+1);
for(j=0;j<5;j++)
printf("%.1f ",score[i][j]);
printf(" ");
}
printf("The average of Course 1 is %.1f . ",cour_aver(score,0));//第一门课程下标是0,不是1.
return 0;
}
float cour_aver(float (*p)[5],int cour)
{
int i;float sum=0;
for(i=0;i<4;i++)
sum=sum+*(*(p+i)+cour);
return sum/4;
}

SQL查询每门课程的平均成绩、选课人数

select 课程, count(课程编号) as 选课人数 , avg(成绩) as 平均成绩 from 表 group by 课程编号

设计一个学生成绩管理系统,学生成绩信息包括:学号,姓名,四门课成绩,实现功能如下:

//我简单写,请借鉴:
#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#include "math.h"
#include "time.h"
#include "string.h"

#include<iostream>
using namespace std;
struct Student            //定义学生结构
{
    char id[20];       //id
    char name[11];     //姓名
    char res[4];       //成绩
    int end;           //存储时显示换行, 可去掉
    Student(){end = 0x0a0d;}  //回车,换行
}list[100];                     //100个账号, 测试
void main()
{
    srand((unsigned)time(0));           //种子
    char buf[256];                 //缓存
    //初始化学生100名
    int i;
    for(i=0;i<100;++i)
    {
        strcpy(list[i].id ,itoa(i,buf,10));                      
        strcpy(list[i].name ,"某人");
        strcpy(list[i].res, itoa(rand()%100,buf, 10));
    }
    //保存数据
    FILE * pf = fopen("data.txt", "wb");
    for(i=0;i<100;++i)
    {
        fwrite(&list[i], sizeof(Student), 1, pf);
    }
    fclose(pf);
    //读出数据
    Student list_1[100];                   //新数组
    pf = fopen("data.txt", "rb");
    for(i=0;i<100;++i)
    {
        fread( &list_1[i], sizeof(Student), 1, pf);
    }
    //显示 list_1 测试
    for(i=0;i<100;++i)          
    {
        cout<<list_1[i].id<<"  "<<list_1[i].name <<"  "<<list_1[i].res<<endl;
    }

}

用C语言编写程序:有五个学生的三门课程的成绩,求每门课程的平均成绩

程序设计思路:首先我们需要定义一个学生的结构体,用于存放学生信息;接着是3个方法,一个输入学生信息的方法,一个是计算学生每门课程平均成绩的,最后一个是输出学生所有信息,包括计算好的平均成绩,具体实现代码如下:
#include <stdio.h>
#include <stdlib.h>#define ARRAY_LEN 100   /*数组长度*/
/*定义学生结构体*/
typedef struct {
int no; /*学号*/
float score1; /*成绩1*/
float score2; /*成绩2*/
float score3; /*成绩3*/
float totalScore; /*总分*/
float averageScore; /*平均分*/
} student;
/*输入学生信息*/
void inputInfo (student stu[], int stuIndex) {
int i;
printf ("第%d名学生↓ ", stuIndex+1);
printf ("学号:");
scanf ("%d",&stu[stuIndex].no);
printf ("成绩1:");
scanf ("%f",&stu[stuIndex].score1);
printf ("成绩2:");
scanf ("%f",&stu[stuIndex].score2);
printf ("成绩3:");
scanf ("%f",&stu[stuIndex].score3);
putchar ( );
}
/*计算平均成绩*/
void calculationScore (student stu[], int stuIndex) {
stu[stuIndex].totalScore=stu[stuIndex].score1+stu[stuIndex].score2+stu[stuIndex].score3;
stu[stuIndex].averageScore=stu[stuIndex].totalScore/3; 
} /*输出学生成绩*/void printInfo (student stu[], int stuIndex) {
int i;
printf ("%d ",stu[stuIndex].no);
printf ("%.2f ",stu[stuIndex].score1);
printf ("%.2f ",stu[stuIndex].score2);
printf ("%.2f ",stu[stuIndex].score3);
printf ("%.2f",stu[stuIndex].averageScore);
putchar ( );
}
int main (void) {
int stuNum=5,i;
student stu[ARRAY_LEN];
/*输入、计算*/
puts ("请输入学生信息:");
putchar ( );
for (i=0; i<stuNum; i++) {
inputInfo (stu,i);
calculationScore (stu,i);
}
putchar ( );
printf ("%d名学生成绩输入完毕!", stuNum);
putchar ( );
puts ("================================================ ");
/*输出*/
puts ("学号 成绩1 成绩2 成绩3 平均成绩");
for (i=0; i<stuNum; i++)
printInfo (stu,i);
getch (); /*屏幕暂留*/
return 0;
}
程序的运行结果:

扩展资料:
具有相同数据类型的数据我们可以用数组来存放,但对于上面的学生信息,包含多种数据类型,所以只能使用结构体来存放。
结构体的定义形式为:
struct 结构体名{
结构体所包含的变量或数组
};
结构体是一种集合,它里面包含了多个变量或数组,它们的类型可以相同,也可以不同,每个这样的变量或数组都称为结构体的成员(Member)。
结构体成员的定义方式与变量和数组的定义方式相同,只是不能初始化。注意大括号后面的分号;不能少,这是一条完整的语句。结构体也是一种数据类型,它由程序员自己定义,可以包含多个其他类型的数据。
像 int、float、char 等是由C语言本身提供的数据类型,不能再进行分拆,我们称之为基本数据类型;而结构体可以包含多个基本类型的数据,也可以包含其他的结构体,我们将它称为复杂数据类型或构造数据类型。

统计选修了课程的学生人数 SQL

意思是统计课程号这一列的总数,并用“学生人数”作为列名来输出,其中还有一个distinct这个关键字,distinct这个关键字来过滤掉多余的重复记录只保留一条。

相关推荐: