當前位置:首頁 » 考試成績 » 學生姓名成績以列表輸出

學生姓名成績以列表輸出

發布時間: 2020-12-24 09:20:15

『壹』 編寫一個程序,輸入學生姓名和分數。輸出以下部分數據

可以將學生姓名和成績的下標聯系在一起,下標一樣的姓名和數據表示的就是一個人。專
程序代碼如下:
#include
#include
#include
void
main()
{
char
name[30][10];
float
score[30];
float
ave;
int
n;
int
i,
j;
cout<<"請輸入學屬生的人數:";
cin>>n;
ave
=
0;
cout<<"請輸入學生的姓名和成績"<
>name[i]>>score[i];
ave
=
ave
+
score[i];
}
ave
=
ave
/
n;
cout<<"本班級平均分是:"<
score[j])
j
=
i;
cout<
評論
0
0
載入更多

『貳』 在一個Excel全年級學生成績表中,我只需要部分學生的成績,怎麼通過姓名將這部分學生的成績從總表中導出

成績表格中的數據都有分類吧,按照班級,學號,可以很快速的分開來。但是如果你只是想通過姓名區分,應該不太好弄。你可以把文件發給我,按照要求我給你導出來。

『叄』 編寫一個程序,已有若干個學生數據(見右表),包括學號,姓名,成績,要求輸出這些學生的信息以及他們總的平均分

#include<iostream>
#include<string>
using namespace std;
class student
{
public:
student(string m,int n,double d);
~student();
static void avg();
void display();
private:
int no;
string name;
double deg;
static double sum;
static double num;
};
student::student(string m,int n,double d)
{
name =m;
no=n;deg=d;
sum+=deg;
num++;
}
student::~student()
{

}
double student::sum=0;
double student::num=0;
void student::avg()
{
cout<<"總分為:"<<sum<<"平均成績:"<<(sum/num)<<endl;
}
void student::display()
{
cout<<"姓名:"<<name<<"學號:"<<no<<"成績:"<<deg<<endl;
}
int main()
{
student s[3]={
student("Li",1,89),
student("chen",2,78),
student("zheng",3,94)};
for(int i=0;i<3;i++)
s[i].display();
student::avg();
return 0;
}

『肆』 編寫程序處理10個學生的信息,輸出成績表,再用一個函數輸出平均分在前3名的學生姓名及平均分。

#include"stdio.h"
#include"stdlib.h" //用於system("pause...");語句
#include"math.h" //用於函數7
#include"string.h"
#include"iostream.h" //fflush(stdin);

int q=0,p=0;

struct stu
{
char name[100];
char cour[10];
float score[100];
};

float f031(struct stu a[])
{
float x;
{
x=(a[q].score[0]+a[q].score[1]+a[q].score[2]+a[q].score[3]+a[q].score[4])/5;
q++;
}
return(x);
}

float f032(struct stu a[])
{
float y[5]; //*
int i;
y[p]=0;
for(i=0;i<10;i++)
y[p]=y[p]+a[i].score[p];
y[p]=y[p]/10;
p++;
return(y[p-1]);
}

float f033(struct stu a[])
{
float c,max=0;
int i,j;
for(i=0;i<10;i++)
for(j=0;j<5;j++)
if(a[i].score[j]>=max)
max=a[i].score[j];

for(i=0;i<10;i++)
for(j=0;j<5;j++)
if(a[i].score[j]==max)
c=a[i].score[j];
return(c);
}

int f034(struct stu a[])
{
float max=0;
int i,j,w;
for(i=0;i<10;i++)
for(j=0;j<5;j++)
if(a[i].score[j]>=max)
max=a[i].score[j];
for(i=0;i<10;i++)
for(j=0;j<5;j++)
if(a[i].score[j]==max)
w=i;
return(w);
}

int f035(struct stu a[])
{
float max=0;
int i,j,r;
for(i=0;i<10;i++)
for(j=0;j<5;j++)
if(a[i].score[j]>=max)
max=a[i].score[j];

for(i=0;i<10;i++)
for(j=0;j<5;j++)
if(a[i].score[j]==max)
r=j;
return(r);
}

float f036(struct stu a[])
{
float x,y=0,z=0;
int i,j;
for(i=0;i<10;i++)
{
x=0;
for(j=0;j<5;j++)
x=x+a[i].score[j];
x=x/5;
y=y+x*x;
z=z+x;
}
return(y/10-(z*z)/(10*10));
}

void main()
{
float f031(a),f032(a),f033(a),f036(a);
int f034(a),f035(a);
struct stu a[100];
int i,j;

printf("此函數為: 輸入10個學生5門課的成績,分別用函數求出:\n (1)每個學生的平均分;(2)每門課的平均分;(3)找出最高的分數所對應的學生和課程;\n(4)求出平均分方差 x0=(x1^+x2^+...+xn^)/n+((x1+x2+...+xn)/n)^ . \n");
printf("請分別輸入五門課程\n");
for(i=0;i<5;i++)
scanf("%s",a[i].cour);

printf("請輸入十個姓名\n");
for(i=0;i<10;i++)
scanf("%s",a[i].name);
printf("請分別輸入十行成績(每行五列)\n");
for(i=0;i<10;i++)
for(j=0;j<5;j++)
scanf("%f",&a[i].score[j]);

printf("輸出為:\n");
printf("姓名");
for(i=0;i<5;i++)
printf("%12s",a[i].cour);
printf("\n");
for(i=0;i<10;i++)
{ printf("%-12s",a[i].name);
for(j=0;j<5;j++)
printf("%-12.1f",a[i].score[j]);
printf("\n");
}

printf("每個學生的平均分為:\n");
for(i=0;i<10;i++)
printf("%-8s%0.1f\n",a[i].name,f031(a));
q=0;
printf("每門課的平均分為:\n");
for(i=0;i<5;i++)
printf("%-12s%0.1f\n",a[i].cour,f032(a));
p=0;
printf("最高的分數所對應的學生和課程為: \n");
printf("%-8.1f%12s%12s\n",f033(a),a[f034(a)].name,a[f035(a)].cour);
printf("平均分方差= ");
printf("%0.2f\n",f036(a));

system("pause...");

}

『伍』 編寫一個程序,輸入學生姓名和分數。輸出以下部分數據

可以將學生姓名和成績的下標聯系在一起,下標一樣的姓名和數據表示的就是一個人。
程序代碼如下:
#include<iostream.h>
#include<string.h>
#include<stdio.h>
void main()
{
char name[30][10];
float score[30];
float ave;
int n;
int i, j;

cout<<"請輸入學生的人數:";
cin>>n;
ave = 0;
cout<<"請輸入學生的姓名和成績"<<endl;
for(i = 0; i < n; i++)
{
cin>>name[i]>>score[i];
ave = ave + score[i];
}
ave = ave / n;
cout<<"本班級平均分是:"<<ave<<endl;
cout<<"考試成績低於班級平均分的學生姓名如下:"<<endl;
for(i = 0; i < n; i++)
if(score[i] < ave)
cout<<name[i]<<endl;
cout<<"最高分以及最高分學生的姓名:"<<endl;
j = 0;
for(i = 1; i < n; i++)
if(score[i] > score[j])
j = i;
cout<<score[j]<<endl;
for(i = 0; i < n; i++)
if(score[i] == score[j])
cout<<name[i]<<endl;
}

『陸』 編程實現:輸入一組學生的姓名和成績,根據成績降序排名。

#include <stdio.h>
#include <string.h>
#define N 3
struct student
{
int score;
char name[20];
};
main()
{
struct student a[N],temp;
int i,j;
for(i=0;i<N;i++)
{
printf("input the %dth student's information:\n",i+1);

printf("name:");
scanf("%s",a[i].name);
printf("score:");
scanf("%d",&a[i].score);

}
for(i=1;i<N;i++)
for(j=0;j<N-i;j++)
if(a[j].score<a[j+1].score)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
printf("名次 姓名 成績\n");
for(i=0;i<N;i++)
printf("%4d%10s%4d\n",i+1,a[i].name,a[i].score);
}

//調試成果 運行正內確容!

『柒』 輸入學生姓名,查找該學生並輸出其學號姓名成績

1、更多交流可參考我空間主頁有關文章。
2、#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
/*定義結構體*/
struct student
{
num;
float score;
struct student *next;
};
/*創建一個只有頭結點的空鏈表*/
struct student *create_head()
{
struct student *head;
head=(struct student*)malloc(sizeof (struct student) );
if(head==NULL) //小心別漏這個
{
printf("申請頭結點失敗!\n");
return NULL;
}
head->next=NULL;
return head;
}
/*將s指向的結點插入鏈表,使鏈表保持升序,並返回頭結點*/
struct student *insert(struct student *head,struct student *s)
{
struct student *p=head;
while(p->next!=NULL&&s->score>p->next->score)//特別注意&&左右不能寫反,若s最大,最後p->next=NULL,p->next->score運行出錯
p=p->next;
if(p->next==NULL) //s->score最大的情況 //其實兩種情況可以並在一塊寫
{
p->next=s; //連接結點
s->next=NULL; //p->next就等於NULL
}
else
{
p->next=s; //連接結點
s->next=p->next;
}
return head ;
}
/*查找符合條件的結點,並返回指向該結點的指針*/
struct student *search(struct student *head)
{
struct student *p=head->next;
int num;
printf("請輸入要查找學生的學號:\n");
scanf("%d",&num);
while(p!=NULL&&p->num!=num) //特別注意兩條件不能寫反,若寫反最後p指向NULL時p->num找不到 運行出錯
p=p->next;
if(p==NULL) //特別注意兩個if不能調換,若調換最後p指向NULL時p->num運行出錯
{
printf("找不到符合條件的結點!!!");
return NULL; //查找不到返回空指針
}
if(p->num==num)
{
printf("找到符合條件的結點\n該結點為%d\t%f",p->num,p->score);
return p; //返回查找到的指針
}
}
/*輸出鏈表各結點的值,也稱對鏈表的遍歷*/
void print(struct student *head)
{
struct student *p;
printf(" 鏈表如下: \n");
p=head->next;
while(p!=NULL)
{
printf("%d\t%.1f\n",p->num,p->score);
p=p->next;
}
}
/*釋放鏈表*/
void free_list(struct student *head)
{
struct student *p=head ;
printf("釋放鏈表:\n");
while(p!=NULL)
{
head=head->next;
free(p);
p=head;
}
printf("釋放鏈表成功!\n");
}
/*刪除鏈表中值為num的結點,並返回鏈表的首指針*/
struct student *delete_note(struct student *head,int num_x)
{
struct student *p1=head->next , *p2=head ;
while(p1!=NULL&&p1->num!=num_x) //特別注意&&左右條件不能調換,若調換如果p1指向NULL時p1->num運行出錯
{
p2=p1;
p1=p1->next;
}
if(p1==NULL) //特別注意兩個if不能調換,若調換如果p1指向NULL時,p1->num運行出錯
printf("找不到符合刪除要求的結點!!!\n");
if(p1->num==num_x)
{
p2->next=p1->next;
free(p1);
printf("結點刪除成功!\n");
}
return head;
}
/*完整的有頭結點鏈表操作程序*/
void main()
{
struct student *p , *head ;
char c;
int num ;
float score ;
printf("有頭結點鏈表操作程序:\n");
head=create_head();
while(1)
{
printf("I:插入結點(自動升序) P:輸出鏈表 S:查找結點 D:刪除結點 E:釋放鏈表並退出程序! ");
c=getch();
switch(c)
{
case'I':
printf("請分別輸入要插入學生的學號和分數:\n");
scanf("%d%f",&num,&score);
p=(struct student*)malloc( sizeof(struct student) );
if(p==NULL)
{
printf("申請該結點失敗!!!\n");
exit (0) ;
}
p->num=num; p->score=score; //給p賦值
insert(head,p);
printf("插入成功!\n");
break;
case'P':
print(head);
break;
case'S':
search(head);
break;
case'D':
printf("請輸入要刪除的學生的學號:\n");
scanf("%d",&num);
delete_note(head,num);
break;
case'E':
free_list(head);
exit (0);
}
}
}

『捌』 可以輸出所有同學的成績表也可以輸出平均分在前3名的學生姓名及平均分怎麼做

今天你是我見過的第三個問這個問題的人了,問題一模一樣,前兩個估計是你的同學了,我幫她們寫了

『玖』 用java定義學生類(學號、姓名、成績)。用列表list存放班級學生信息。然後按照成績排序,並輸出學生信息

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Admin {

public static void main(String... args) {
List data = new ArrayList();

Student s0 = new Student();
s0.setNo("000");
s0.setName("a");
s0.setChengji(100.0);
data.add(s0);

Student s1 = new Student();
s1.setNo("001");
s1.setName("b");
s1.setChengji(99.0);
data.add(s1);

Student s2 = new Student();
s2.setNo("002");
s2.setName("c");
s2.setChengji(98.0);
data.add(s2);

System.out.println("排序前");
show(data);

System.out.println("排序後");
sort(data);
show(data);
}

private static void sort(List data) {
Collections.sort(data, new Comparator() {

public int compare(Object o1, Object o2) {
Student s1 = (Student) o1;
Student s2 = (Student) o2;
return (int) (s1.getChengji() - s2.getChengji());
}
});
}

private static void show(List data) {
for (int i = 0; i < data.size(); i++) {
System.out.println(data.get(i));
}
}
}

class Student {

private String no;

private String name;

private double chengji;

public double getChengji() {
return chengji;
}

public void setChengji(double chengji) {
this.chengji = chengji;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getNo() {
return no;
}

public void setNo(String no) {
this.no = no;
}

public String toString() {
return "學號:" + no + ",姓名:" + name + ",成績:" + chengji;
}
}
結果
排序前
學號:000,姓名:a,成績:100.0
學號:001,姓名:b,成績:99.0
學號:002,姓名:c,成績:98.0
排序後
學號:002,姓名:c,成績:98.0
學號:001,姓名:b,成績:99.0
學號:000,姓名:a,成績:100.0

『拾』 SQL查詢成績60以上的學生姓名,且姓名只輸出一次

沒有表結構,我就大致寫個示意的sql。
select distinct 姓名 from 表 where 成績>60;
如果需要多表查詢就做一下表關聯。
如果有幫助到你,請點擊採納。

熱點內容
武漢大學學生會輔導員寄語 發布: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