10个学生的5种成绩
㈠ 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;
}