當前位置:首頁 » 考試成績 » 計算一個班學生某門功課的總評成績

計算一個班學生某門功課的總評成績

發布時間: 2021-03-06 17:08:16

『壹』 編寫程序,輸入一個班40個學生某門課程的成績,求所有成績的平均分數,並輸出到顯示器。

#include<stdio.h>
void main(){
float a[10],b[10],sum=0;
int i,j,count=0;
for(i=0;i<10;i++){
scanf("%f",&a[i]);
sum=sum+a[i];
if(a[i]<60)
count++;
}
printf("不及格抄人數襲為:%d\n平均成績為:%f\n",count,sum/10);
}

『貳』 編寫一個程序,計算若干學生的某門功課的平均成績,找出最高分和最低分(c語言作業,不太會,拜託了)

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N 5
void main()
{
float a[N],aver,stdev,max,min;
int i;
for(i=0;i<N;i++)
scanf("%f",&a[i]);
aver=0;max=min=a[i]=0;
for(i=0;i<N;i++)
{aver=aver+a[i];
if(max<a[i]) max=a[i];
if(min>a[i]) min=a[i];}
aver=aver/N;
stdev=0;
for(i=0;i<N;i++)
stdev=stdev+(a[i]-aver)*(a[i]-aver);
stdev=sqrt(stdev/N);

for(i=0;i<N;i++)

printf("%f,%f,%f,%f,%f",aver,stdev,max,min);
}

『叄』 如何用結構體和鏈表實現輸入一個班學生的所有成績求每門課的總成績

#include<stdio.h>
#include<stdlib.h>
#define N 5
float score[N]={0};
float sum[N]={0};
struct student
{
int iNum;
float fScore[N];
struct student *pStrNext;
};
/*創建鏈表*/
struct student * create()
{ struct student *pStrStuHead=0,*pStrStuTemp,*pStrStuTail=0;
int iNumTemp,i,j;
float fScoreTemp[N];
printf("input num (>=0, <0 end):\n");
scanf("%d",&iNumTemp);
printf("input score\n");
for(i=0;i<N;i++){scanf("%f",&fScoreTemp[i]);}
/* 添加結點,當輸入成績值為負數時結束 */
while(fScoreTemp[1]>0)
{ /*申請結點並填入數據,結點的指針域為0,因為新結點將作為最後一個結點*/
pStrStuTemp=(struct student*)malloc(sizeof(struct student));
pStrStuTemp->iNum=iNumTemp;
for(j=0;j<N;j++)pStrStuTemp->fScore[j]=fScoreTemp[j];
pStrStuTemp->pStrNext=0;
/*接入鏈表*/
if(!pStrStuHead)
/*接入第一個結點,頭指針、尾指針均指向該結點*/
pStrStuHead=pStrStuTail=pStrStuTemp;
else {
/*接入非第一個結點*/
pStrStuTail->pStrNext=pStrStuTemp;/*接在尾指針所指結點之後*/
pStrStuTail=pStrStuTemp;/*尾指針指向新加入結點*/ }
printf("input num (>=0, <0 end):\n");
scanf("%d",&iNumTemp);
printf("input score\n");
for(i=0;i<N;i++){scanf("%f",&fScoreTemp[i]);} }
return pStrStuHead; }
/*輸出鏈表*/
void average(struct student *pStrStuHead)
{
int i=0;
int j;
int number=0;
while(pStrStuHead)
{for(j=0;j<N;j++)
{sum[i]+=pStrStuHead->fScore[j];}/*輸出*/
pStrStuHead=pStrStuHead->pStrNext;/*移動到下一個結點*/
number++;
}
for(i=0;i<N;i++)
{ score[i]=sum[i]/number;
printf("第%d門平均分:%f",i,score[i]);
}
}

int main()
{
struct student *pStrStuHead;

/*創建鏈表*/
pStrStuHead=create();
/*輸出鏈表所有平均分*/
average(pStrStuHead);

return 0;
}

『肆』 c#編寫一個學生成績計算程序,統計出一個班學生的某門課程各分數段的人數(分數段:90分以上,80-90,70-80,

int[] score = new int[10]; string[] m = { };
int i, a, b, c, d, e;
a = b = c = d = e = 0;
double t = 0, max, min, r;
Console.WriteLine("請輸入名學生的成績 以回車符區分");
for (i = 0; i < 10; i++)
{
int inputScore = 0;
if (!int.TryParse(Console.ReadLine(), out inputScore))
{
Console.WriteLine("請輸入數字類型成績");
i--;
}
score[i] = inputScore;
}

for (i = 0; i < 10; i++)
{
switch (score[i] / 10)
{
case 10:
case 9: a++; break;
case 8: b++; break;
case 7: c++; break;
case 6: d++; break;
default: e++;
break;
}
}

max = score[0];
min = score[0];
for (i = 0; i < 10; i++)
{
t += score[i];
if (score[i] > max) max = score[i];
if (score[i] < min) min = score[i];
}
r = t / 10;
Console.WriteLine("平均分為:{0}", r);
Console.WriteLine("最高分為:{0}", max);
Console.WriteLine("最低分為:{0}", min);

Console.WriteLine("得優人數 :{0}", a);
Console.WriteLine("得良人數 : {0}", b);
Console.WriteLine("得好人數 :{0}", c);
Console.WriteLine("及格人數 :{0}", d);
Console.WriteLine("不及格人數 :{0}", e);
Console.ReadLine();

『伍』 編寫一個程序實現一個班級學生某門課程的成績管理,學生(姓名,學號,出生日期(日期類),成績)。

using System; using System.Collections.Generic; using System.Text; namespace stuConsole { //定義學生類 class student { //欄位定義 private string name; //姓名 private string no; //學號 private double engScore; //英語成績 private double cScore; //C++成績 private double mathScore; //數學成績 //定義屬性,通過屬性訪問、修改相應欄位 public string Name { set{name = value;} get{return name;} } public string No { set{no = value;} get{return no;} } public double EngScore { set{engScore = value;} get{return engScore;} } public double CScore { set{cScore = value;} get{return cScore;} } public double MathScore { set { mathScore = value; } get { return mathScore; } } //輸入相應的數據 public void inputText() { Console.WriteLine("請輸入姓名:"); Name = Console.ReadLine(); Console.WriteLine("請輸入學號:"); No = Console.ReadLine(); Console.WriteLine("請輸入英語成績:"); EngScore = double.Parse(Console.ReadLine()); Console.WriteLine("請輸入C++成績:"); CScore = double.Parse(Console.ReadLine()); Console.WriteLine("請輸入數學成績:");

『陸』 找錯!c++設計一個學生類,求N名學生某門功課的總成績和平均分 ;鏈棧

錯誤有點多, 下面改了幾個。
#include<iostream.h>
#include"malloc.h"
struct student
{char name[20];
int score;
}stu[5];

class informatoin
{
public:
informatoin(int a,int b,int c,int d,int e,int f);
void GetName();
void GetScore();
int GetSum();
float GetAverage();
private :
char name[20];
float score;
static int Sum;
static float Average;
};
/*int informatoin::Sum(0); 你這里是想初始化吧,私有成員不能在類外直接使用
float informatoin::Average(0);*/
informatoin:: informatoin(int a,int b,int c,int d,int e,int f)
{
int i;
stu[0].score=a;stu[1].score=b;stu[2].score=c;stu[3].score=d;stu[4].score=e;
for(i=0;i<5;i++)
{
Sum+=stu[i].score;
}
Average=float (Sum/5);
}

void informatoin::GetScore()
{
int i=0;
for(i=0;i<5;i++)
cout<<stu[i].score<<endl;
}

int informatoin::GetSum()
{return informatoin::Sum;}
float informatoin::GetAverage()
//float informatoin::GetAverage();
{return informatoin::Average;}

void main()
{
int i;
student stu[5];
informatoin ss();
//information ss(); //你的類名是informatoin不是information
cout<<"input the name and the score:"<<endl;
for(i=0;i<5;i++)
{
cin>>stu[i].name>>stu[i].score;
}
cout<<"sum score is:"<<ss.GetSum()<<endl;
cout<<"average score is:"<<ss.GetAverage()<<endl;
}

//#include "malloc.h" 最好放在程序的開頭處(和#include<iostream.h>在一起)

struct list
{
int data;
list *next;
};

class stack
{
list *ptr;
public:
stack(){ptr=NULL;}
void push(int i);
int pop();
int getTop();
bool IsEmpty();};

bool stack::IsEmpty()
{if ( ptr ==NULL )
{return true;
cout<<"this stack is empty"<<endl;}
else
return false;
}

void stack::push(int x)
{
list *newnode=new list;
int i;
for(i=0;i<malloc(sizeof(list));i++) cin>>x;
newnode->data=x;
newnode->next=ptr;
ptr=newnode;
}

int stack::pop()
{list *top;
int value;
while(!IsEmpty())
{
value=ptr->data;
top=ptr;
ptr=ptr->next;
delete top;
return value;
}
}

int stack:: getTop()
{int value;
while(!IsEmpty())
{value=ptr->data;
return value;}
}

//#include <iostream.h>
//#include"stack.h"
/*void main()
{int i; int x;
stack st;
cout<<"input a stack :"<<endl;
st.push(x);
cout<<"the stack is:"<<endl;
st.pop();
st.IsEmpty();
{if(true)
cout<<"stack is empty"<<endl;
else if(false)
cout<<"stack is not empty"<<endl;}
}*/

『柒』 c語言。編寫一個程序,輸入全班同學某門課考試成績,計算平均成績並統計大於等於平均成績的人數。

#include<stdio.h>

main()

{

doublegrade[200];

doublesum,avg,temp;

intcount,i,n;

i=0;

count=0;

sum=0;

printf("請依次輸入每個同學的成績,輸入-1結束 ");

scanf("%lf",&temp);

while(temp!=-1)

{

grade[i++]=temp;

count++;

sum=sum+temp;

scanf("%lf",&temp);

}

avg=sum/count;

n=0;

for(i=0;i<count;i++)

{

if(grade[i]>=avg)

n++;

}

printf("全班平均分%.2lf,成績大於等於平版均分的人有權%d人 ",avg,n);

}

『捌』 已知某班有n個學生一門課的成績,計算平均成績,最高成績和最低成績

平均成績=(總成績÷班裡學生n)
最高成績和最低成績可以通過
Excel表格
升序或者降序排列看出

『玖』 下列程序要求: 輸入學生某門功課的成績,計算各成績等級的人數

#include <stdio.h>
int main(int argc, constchar * argv[])
{
int score[100]={0};
int a=0,b=0,c=0;
printf("請輸入學生的成績,總人數為14\n");
for (int i=0; i<14; i++) {
scanf("%d",&score[i]);
}
for (int i=0; i<14; i++) {
if (score[i]>=80) {
a++;
}
elseif (score[i]>=60&&score[i]<=79){
b++;
}
elseif (score[i]<60){
c++;
}
}
printf("a等級的人數為:內容%d,b等級的人數為:%d,c等級的人數為:%d",a,b,c);
return0;
}

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919