當前位置:首頁 » 考試成績 » 10個學生的5種成績

10個學生的5種成績

發布時間: 2020-12-29 20:11:43

㈠ c語言,10個學生有5門課的成績,假設成績范圍為60~100,分別用子函數實現下面功能

//希望我的回答對你的學習有幫助
//竭盡全力按照你圖片提供的信息製作的表格
//但是你給的圖片有的地方比較模糊
//無法做出判斷的地方,使用『*』號代替
//表格其他項,使用程序中定義的變數代替
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

intmain()
{
intscore[10][5];
doublea_stu[10]={},a_cour[5]={};
srand(unsigned(time(NULL)));//產生隨機種子

for(inti=0;i<10;i++)
{
for(intj=0;j<5;j++)
{
score[i][j]=rand()%(101-60)+60;
a_stu[i]+=score[i][j];
a_cour[j]+=score[i][j];
if(j==4)a_stu[i]/=5;
if(i==9)a_cour[j]/=10;
}
}

printf("***cour-1cour-2cour-3cour-4cour-5a_stu ");
for(inti=0;i<10;i++)
{
printf("stu_%2d%10d%10d%10d%10d%10d%10.2lf ",i+1,score[i][0],score[i][1],score[i][2],score[i][3],score[i][4],a_stu[i]);

}
printf("a_cour%11.2lf%11.2lf%11.2lf%11.2lf%11.2lf ",a_cour[0],a_cour[1],a_cour[2],a_cour[3],a_cour[4]);

return0;
}

㈡ 將前10%成績最低的學生的成績減去5分

這樣你就不是最難堪的?

㈢ 輸入10個學生5門成績,分別用函數實現下列功能:

你好!

#include<stdio.h>
staticfloatb[10],c[5],d[5];
staticinta[10][5],name,course;

intaverage1(intm[10][5])
{
inti,j;
for(i=0;i<10;i++){
for(j=0;j<5;j++)
b[i]=b[i]+m[i][j];
b[i]=b[i]/5;
}
return0;
}

intaverage2(intm[10][5])
{
inti,j;
for(j=0;j<5;j++){
for(i=0;i<10;i++)
c[j]=c[j]+m[i][j];
c[j]=c[j]/10;
}
return0;
}

intmaxscore(intm[10][5])
{
floatmax=0;
inti,j;
for(i=0;i<10;i++)
for(j=0;j<5;j++)
if(m[i][j]>max){
max=m[i][j];
name=i;
course=j;
}
return0;
}


intaverage3(floatm1[],intm[10][5])
{
floats1=0,s2=0;
inti,j;
for(i=0;i<5;i++)
{
for(j=0;j<10;j++)
{
d[i]=(m1[i]-m[j][i])*(m1[i]-m[j][i]);
}
d[i]=d[i]/10.0;
}
}

main(){
inti,j;
for(i=0;i<10;i++){
printf("Inputscores: ");
for(j=0;j<5;j++)
scanf("%d",&a[i][j]);
}
average1(a);
average2(a);
maxscore(a);
average3(c,a);
printf("everystudent'saveragescore: ");
for(i=0;i<10;i++)
printf("%f",b[i]);
printf(" ");
printf("everycourse'saveragescore: ");
for(i=0;i<5;i++)
printf("%f",c[i]);
printf(" ");
printf("maxscore: ");
printf("student:%d,course:%d ",name+1,course+1);

for(i=0;i<5;i++)
printf("averagescores'variance:%.6f ",d[i]);
}

㈣ 用C語言,輸入一個班10個學生的成績,統計各分數段[0,60),[60,70),[70,80),[80,90),[90-100]的人數。

這個是你要的程序,vc6.0通過調試運行了版。
#include<stdio.h>
void main()
{
int no=1,count[5]={0,0,0,0,0};
float score;
for(;no<=10;no++)
{
權printf("input a score:\n");
scanf("%f",&score);
if(score>=0&&score<60)
count[0]++;
if(score>=60&&score<70)
count[1]++;
if(score>=70&&score<80)
count[2]++;
if(score>=80&&score<90)
count[3]++;
if(score>=90&&score<=100)
count[4]++;
}
printf("0~60:%d\n60~70:%d\n70~80:%d\n80~90:%d\n90~100:%d\n",count[0],count[1],count[2],count[3],count[4]);
}

㈤ 有10個學生,每個學生的數據包括學號,姓名,三門課的成績,從文件中讀取學生數據,要求輸出每位學生的

|

模擬數據如下:

001|張三|85.5|79.0|92.0
002|李四|58.0|99.0|78.5
003|王五|88.0|51.0|63.0
004|孫六|84.0|88.0|92.0
005|杜七|52.0|51.0|43.0
006|劉八|96.0|100.0|99.0
007|錢九|61.0|77.0|79.5
008|周十|59.5|60.0|62.0
009|吳邪|88.0|92.0|75.0
010|鄭州|78.0|91.0|99.0
importjava.math.BigDecimal;

/**
*學生類
*/
publicclassStudent{

/**
*學號
*/
privateStringcode;

/**
*姓名
*/
privateStringname;

/**
*語文
*/
privatedoublechinese;

/**
*數學
*/
privatedoublemath;

/**
*英語
*/
privatedoubleenglish;

/**
*總分
*/
privatedoubletotal;

/**
*平均分
*/
privatedoubleaverage;

publicStudent(){
}

publicStudent(Stringcode,Stringname,doublechinese,doublemath,doubleenglish){
this.code=code;
this.name=name;
this.chinese=chinese;
this.math=math;
this.english=english;
}

publicStudent(String[]properties){
this(properties[0],properties[1],
newBigDecimal(properties[2]).doubleValue(),
newBigDecimal(properties[3]).doubleValue(),
newBigDecimal(properties[4]).doubleValue());
}

publicdoublecalculateTotal(){
this.total=this.chinese+this.math+this.english;
returnthis.total;
}

publicdoublecalculateAverage(){
average=(this.chinese+this.math+this.english)/3;
average=BigDecimal.valueOf(average).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
returnaverage;
}

publicStringgetCode(){
returncode;
}

publicvoidsetCode(Stringcode){
this.code=code;
}

publicStringgetName(){
returnname;
}

publicvoidsetName(Stringname){
this.name=name;
}

publicdoublegetChinese(){
returnchinese;
}

publicvoidsetChinese(doublechinese){
this.chinese=chinese;
}

publicdoublegetMath(){
returnmath;
}

publicvoidsetMath(doublemath){
this.math=math;
}

publicdoublegetEnglish(){
returnenglish;
}

publicvoidsetEnglish(doubleenglish){
this.english=english;
}

publicdoublegetTotal(){
returntotal;
}

publicvoidsetTotal(doubletotal){
this.total=total;
}

publicdoublegetAverage(){
returnaverage;
}

publicvoidsetAverage(doubleaverage){
this.average=average;
}
}
importjava.io.*;
importjava.util.ArrayList;
importjava.util.HashMap;
importjava.util.List;
importjava.util.Map;

publicclassTest{

/**
*根據實際情況修改路徑,我是MAC系統
*/
privatestaticfinalStringDATA_INPUT_FILE="/Users/liuchongguang/Downloads/scores.txt";

/**
*根據實際情況修改路徑,我是MAC系統
*/
privatestaticfinalStringDATA_OUTPUT_FILE="/Users/liuchongguang/Downloads/scores_result.txt";

privatestaticList<Student>loadStudents(StringfilePath){
List<Student>students=newArrayList<Student>();
InputStreamis=null;
InputStreamReaderisr=null;
BufferedReaderbr=null;
try{
is=newFileInputStream(newFile(filePath));
isr=newInputStreamReader(is,"UTF-8");
br=newBufferedReader(isr);
Stringline=null;
while((line=br.readLine())!=null){
String[]properties=line.split("\|");
students.add(newStudent(properties));
}
}catch(Exceptione){
e.printStackTrace();
returnnull;
}finally{
try{
br.close();
isr.close();
is.close();
}catch(Exceptione){
e.printStackTrace();
}
}
returnstudents;
}

privatestaticvoidsaveStudents(StringfilePath,List<Student>students,Map<String,Map<Double,List<Student>>>totalStudents,
Map<String,Map<Double,List<Student>>>chineseStudents,Map<String,Map<Double,List<Student>>>mathStudents,
Map<String,Map<Double,List<Student>>>englishStudents){
FileWriterfw=null;
BufferedWriterbw=null;
try{
Filefile=newFile(filePath);
if(!file.exists()){
file.createNewFile();//不存在則創建
}
fw=newFileWriter(file,false);
bw=newBufferedWriter(fw);
for(Studentstudent:students){
bw.write("[學號:"+student.getCode()+","+student.getName()+"]語文:"
+student.getChinese()+",數學:"+student.getMath()+",英語:"+student.getEnglish()+
"總分:"+student.getTotal()+",平均分:"+student.getAverage()+" ");
}
bw.write(" ");
saveStudents(bw,chineseStudents,"語文");
saveStudents(bw,mathStudents,"數學");
saveStudents(bw,englishStudents,"英語");
saveStudents(bw,totalStudents,"總分");
}catch(Exceptione){
e.printStackTrace();
}finally{
try{
bw.close();
fw.close();
}catch(Exceptione){
e.printStackTrace();
}
}
}

privatestaticvoidsaveStudents(BufferedWriterbw,Map<String,Map<Double,List<Student>>>map,Stringlanguage)throwsException{
bw.write("=============================="+language+"成績統計============================== ");
Map<Double,List<Student>>highMap=map.get("high");
Doublescore=(Double)highMap.keySet().toArray()[0];
List<Student>students1=highMap.get(score);
bw.write(language+"成績最高分:"+score+",獲得者:");
for(Students:students1){
bw.write("[學號:"+s.getCode()+","+s.getName()+"]");
}
bw.write(" ");
Map<Double,List<Student>>lowMap=map.get("low");
score=(Double)lowMap.keySet().toArray()[0];
students1=lowMap.get(score);
bw.write(language+"成績最低分:"+score+",獲得者:");
for(Students:students1){
bw.write("[學號:"+s.getCode()+","+s.getName()+"]");
}
bw.write(" ");
bw.write(" ");
}

privatestaticvoidcalculate(List<Student>students,Map<String,Map<Double,List<Student>>>totalStudents,
Map<String,Map<Double,List<Student>>>chineseStudents,
Map<String,Map<Double,List<Student>>>mathStudents,
Map<String,Map<Double,List<Student>>>englishStudents){
for(Studentstudent:students){
student.calculateTotal();
student.calculateAverage();
compare(totalStudents,student.getTotal(),student);
compare(chineseStudents,student.getChinese(),student);
compare(mathStudents,student.getMath(),student);
compare(englishStudents,student.getEnglish(),student);
}
}

privatestaticvoidcompare(Map<String,Map<Double,List<Student>>>map,doublescore,Studentstudent){
if(map.keySet().size()==0){
HashMap<Double,List<Student>>highMap=newHashMap<Double,List<Student>>();
HashMap<Double,List<Student>>lowMap=newHashMap<Double,List<Student>>();
List<Student>students=newArrayList<Student>();
students.add(student);
highMap.put(score,students);
lowMap.put(score,students);
map.put("high",highMap);
map.put("low",lowMap);
}else{
Map<Double,List<Student>>highMap=map.get("high");
Doublekey=(Double)highMap.keySet().toArray()[0];
if(key==score){
List<Student>students=highMap.get(key);
students.add(student);
}elseif(key<score){
highMap.clear();
highMap=newHashMap<Double,List<Student>>();
List<Student>students=newArrayList<Student>();
students.add(student);
highMap.put(score,students);
map.put("high",highMap);
}

Map<Double,List<Student>>lowMap=map.get("low");
key=(Double)lowMap.keySet().toArray()[0];
if(key==score){
List<Student>students=lowMap.get(key);
students.add(student);
}elseif(key>score){
lowMap.clear();
lowMap=newHashMap<Double,List<Student>>();
List<Student>students=newArrayList<Student>();
students.add(student);
lowMap.put(score,students);
map.put("low",lowMap);
}
}
}

publicstaticvoidmain(String[]args){
//從文件中讀取學生數據
List<Student>students=loadStudents(DATA_INPUT_FILE);
//總分最高分和最低分
Map<String,Map<Double,List<Student>>>totalStudents=newHashMap<String,Map<Double,List<Student>>>();
//語文最高分和最低分
Map<String,Map<Double,List<Student>>>chineseStudents=newHashMap<String,Map<Double,List<Student>>>();
//數學最高分和最低分
Map<String,Map<Double,List<Student>>>mathStudents=newHashMap<String,Map<Double,List<Student>>>();
//英語最高分和最低分
Map<String,Map<Double,List<Student>>>englishStudents=newHashMap<String,Map<Double,List<Student>>>();

//計算結果
calculate(students,totalStudents,chineseStudents,mathStudents,englishStudents);

//保存結果至文件
saveStudents(DATA_OUTPUT_FILE,students,totalStudents,chineseStudents,mathStudents,englishStudents);
}
}

㈥ c語言錄入10個學生信息,包括學號姓名,5門課成績,並要求錄入學生各科成績,總分,最高最低分,前五名

#include <stdio.h>
#include <math.h>
typedef struct student{
char num[10];
char name[5];
int score1[50],score2[50],score3[50],score4[50],score5[50];
int sum[10];
struct student *p;
}N;
N *ks(){
N *head,*next,*end,sum[10];
head=(N*)malloc(sizeof(N));
next=head;
for(int i=0;i<10;i++){
printf("請第%d次輸入學號,性別,名字,5科成績\n",i+1);
end=(N*)malloc(sizeof(N));
scanf("%s%s%d%d%d%d%d",&end->num,&end->name,&end->score1,&end->score2,&end->score3,&end->score4,&end->score5);
next->p=end;
next=end;
}
end->p=NULL;
return head;
}
void bl(N *head){
int S[10],F[100],f[100],K[20];
int V1[20],V2[20],V3[20],V4[20],V5[20];
N *end=head->p;
int i=0;
char N[10];
float v1,v2,v3,v4,v5;
while(end){
if(i==0)printf("總分前5學%s的score1分數是%dscore2分數是%d\nscore3分數是%dscore4分數是%dscore5分數是%d",end->num,*end->score1,*end->score2,*end->score3,*end->score4,*end->score5);
if(i==2)printf("總分前5學號%s的score1分數是%dscore2分數是%d\nscore3分數是%dscore4分數是%dscore5分數是%d",end->num,*end->score1,*end->score2,*end->score3,*end->score4,*end->score5);

㈦ c語言。輸入10個學生課程成績,輸出最高分,最低分平均分

#include<stdio.h>
floatmax=0,min=100,sum=0;
floatf(float*a,intn)
{
inti;
floatav;
for(i=0;i<n;i++)
{
if(a[i]>max)
max=a[i];
elseif(a[i]<min)
min=a[i];
sum=sum+a[i];
}
av=sum/n;
return(av);
}
voidmain()
{
floats2[10]={67.5,89.5,99,69.5,77,89.5,76.5,54,60,99.5};
printf("平均成績抄:%f ",f(s2,10));
printf("總成績:%f ",sum);
printf("最高分:%f ",max);
printf("最低分:%f ",min);
}

㈧ 請大家看一個c程序:輸入10個學生5門成績,分別用函數實現下列功能:

我來解決吧,朋友,俺不要分的,嘿嘿。
r=0; c=1; 是給r,c賦初值。
h=highest(&r,&c);是調用的float highest(r,c) 來求最大值,參內數為r,c這兩個東東的地址,容而函數的具體內容你可以多看一下,主要是for語句的使用,然後如果某個學生的某門成績比初始默認的那個值大,就會將那個最大值替代,同時r,c的位置也會一直停留在成績最大的那個位置。從而函數調用完後輸出,則能得出最大成績,第幾個學生,第幾門成績。
*r=i+1;
*c=j+1;
則是經if語句判斷後,若產生新的最大值,則將原先的第幾個學生,第幾門成績替換了。
只能講這些了,哪裡不懂可以再給我留言。

對了,你的那個float highest(r,c) int *r,*c;
幹嘛不寫成float highest(int *pr,int *pc); 形參最好與實參不用同一個東東,便於區別。

㈨ C語言 編程!!!二、實驗題目: 有10個學生,每個學生的數據包括學號,姓名,及三門課成績,總,平均。

#include(stdio.h)

float score[4];

}person[10];

int i;

printf("請輸入10名學生的學號、姓名、及三門成績:");

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

printf("學號:%d 姓名:%s 成績:%d %d %d 平均成績:%d ",person[i]->number,person[i]->name[20],person->score[0],person->score[1],person->score[2],person->score[3]);

}

擴展資版料:

在C語言家族權程序中,頭文件被大量使用。一般而言,每個C++/C程序通常由頭文件和定義文件組成。頭文件作為一種包含功能函數、數據介面聲明的載體文件,主要用於保存程序的聲明,而定義文件用於保存程序的實現。

不像 COBOL、Fortran 和 PL/I等編程語言,在 C 語言的工作任務里不會包含嵌入的關鍵字,所以幾乎所有的 C 語言程序都是由標准函數庫的函數來創建的。

㈩ 已知10個學生5門課程的成績,將其存入一個二維數組,求每一個學生的總成績和平均成績。

#include<stdio.h>
#include<stdlib.h>
intmain()
{
//float二維數組
floata[10][5];
//變數自i,j
inti,j;
//定義sum,average並初始化每一個元素
floatsum[10]={0},average[10]={0};
//循環輸入每個元素
for(i=0;i<10;i++)
for(j=0;j<5;j++)
scanf("%f",&a[i][j]);
//求sum與average
for(i=0;i<10;i++)
{
for(j=0;j<5;j++)
{
sum[i]=sum[i]+a[i][j];
average[i]=sum[i]/5.0;
}
}
//循環輸出
for(i=0;i<10;i++)
printf("%f%f ",sum[i],average[i]);
//程序正常結束
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