有10个学生,每个学生的数据包括学号、姓名、三门课的成绩,从键盘输入10个学生数据,要求打印出3门课的总

作者&投稿:李闻 (若有异议请与网页底部的电邮联系)
#include "stdio.h"
#include <stdlib.h>
#define SIZE 10

struct student{
char id[20];
char name[20];
int score[3];
int total;
} stud[SIZE];

void main()
{
int i,j;
struct student temp;
for(i=0;i<SIZE;i++)
{
printf("第%d个学生的信息:\n",i+1);
scanf("%s%s%d%d%d",stud[i].id,stud[i].name,&stud[i].score[0],&stud[i].score[1],&stud[i].score[2]);
stud[i].total=stud[i].score[0]+stud[i].score[1]+stud[i].score[2];
}
for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE-i-1;j++)
{
if(stud[j].total<stud[j+1].total)
{
temp=stud[j];
stud[j]=stud[j+1];
stud[j+1]=temp;
}
}
}
printf("\n");
for(i=0;i<SIZE;i++)
printf("%s %s %d %d %d %d\n",stud[i].id,stud[i].name,stud[i].score[0],stud[i].score[1],stud[i].score[2],stud[i].total);
}

# include<stdio.h>
# define N 10
struct student
{
int num;
char name[20];
float score[3];
float total;
float aver;
} ;

void main()
{ void input(struct student s[]);
void sort(struct student s[]);
void print(struct student s[]);
struct student stu[N],* p=stu;
input(p);
sort(p);
print(p);
}

void input(struct student s[])
{ int i;
printf("please enter num,name and 3 scores:\n");
for(i=0;i<N;i++)
{
scanf("%d %s %f %f %f",&s[i].num,s[i].name,&s[i].score[0],&s[i].score[1],&s[i].score[2]);
s[i].total=s[i].score[0]+s[i].score[1]+s[i].score[2];
s[i].aver=s[i].total/3.0;
}
}

void sort(struct student s[])
{
struct student t;
int i,j,k;
for(i=0;i<N-1;i++)
{k=i;
for(j=i+1;j<N;j++)
if(s[j].aver>s[k].aver) k=j;
t=s[k];s[k]=s[i];s[i]=t;
}
}

void print(struct student s[])
{ int i;
printf("the sorted result is:\n");
printf(" num name score1 score2 score3 total aver\n");
for(i=0;i<N;i++)
printf("%5d %-9s %-6.1f %-6.1f %-6.1f %-6.1f %-6.1f\n",s[i].num,s[i].name,s[i].score[0],s[i].score[1],s[i].score[2],s[i].total,s[i].aver);
}

C语言编程题:有10个学生,每个学生数据包括学号,姓名,3门课的成绩,从键盘输入10个学生数据,~

#include(stdio.h)
main()
{struct student
{long number;
char name[20];
float score[4];
}person[10];
int i;
printf("请输入10名学生的学号、姓名、及三门成绩:");
for(i=0;i<10;i++)
scanf("%d,%s,%d,%d,%d",&person[i]->number,person[i]->name,&person->score[0],&person->score[1],&person->score[2]);
for(i=0,i<10;i++)
person->score[3]=(person->score[0]+person->score[1]+person->score[2])/3;
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语言提供了许多低级处理的功能,但仍然保持着良好跨平台的特性,以一个标准规格写出的C语言程序可在许多电脑平台上进行编译,甚至包含一些嵌入式处理器(单片机或称MCU)以及超级电脑等作业平台。

#include "stdio.h"
#include
#define SIZE 10

struct student{
char id[20];
char name[20];
int score[3];
float average;
} stud[SIZE];

void input() /* 输入学生的信息 */
{
int i;

for(i=0;i<SIZE;i++)
{
printf("第%d个学生的信息:
",i+1);
scanf("%s%s%d%d%d",stud[i].id,stud[i].name,&stud[i].score[0],&stud[i].score[1],&stud[i].score[2]);
stud[i].average=(stud[i].score[0]+stud[i].score[1]+stud[i].score[2])/3.0;
}
}


void output() /* 输出学生的信息 */
{
int i;

printf("
");
for(i=0;i<SIZE;i++)
printf("%s %s %d %d %d %3.1f
",stud[i].id,stud[i].name,stud[i].score[0],stud[i].score[1],stud[i].score[2],stud[i].average);
}

void sortput() /* 排序输出最高分的学生信息 */
{
int i,j;
struct student temp;

for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE-i-1;j++)
{
if(stud[j].average<stud[j+1].average)
{
temp=stud[j];
stud[j]=stud[j+1];
stud[j+1]=temp;
}
}
}
printf("
%s %s %d %d %d %3.1f
",stud[0].id,stud[0].name,stud[0].score[0],stud[0].score[1],stud[0].score[2],stud[0].average);
}

void main()
{
input();
output();
sortput();
}

有十个学生,每个学生的数据包括学号,姓名,成绩。从键盘中输入十个学生...
答:写了一个比你需要的功能还完善的程序,在附件里,下面是运行截图:你用我的程序的时候把 #define N 1000 改为#define N 10 就可以了

有十个学生。每个学生包括学号,姓名,和三门成绩。从键盘输入十个学生的...
答:if(n<10)p1=(struct student*)malloc(len);scanf("%d,%s,%d,%d,%d",&p1->num,&p1->name,&p1->score[1],&p1->score[2],&p1->score[3]);} p2->next=null;return(head);} void main(){ struct student *p,*p3;int max=0;int i;int sum=0;p=creat(); /// while(p->ne...

C++结构体的运用
答:/ (1)职工数据包括:职工号、职工姓名、性别、年龄、工资、地址。为其定义一个结构体变量,对该变量,从键盘输入所需的具体数据,然后通过printf函数显示出来。(2)有10个学生,每个学生的数据包括学号、姓名、3门课的成绩,从键盘输入10个学生数据,要求输出每个学生3门课程总平均成绩。/ define MAX...

C语言实验题 求大神指点
答:// 注意:你所指的最高学分,是指总成绩还是单科?下面我是按单科最高学分来求的。#include<stdio.h>#define STU_NUMBER 2 // 假设只有2个学生(你可以把2改为10)#define SCORE_NUMBER 4struct StudentInfo{int stu_id;char name[10];float score[4];float average;float score_sum;};// ...

.有10名学生的数据(包括学号、姓名、和三门课程的成绩即,数学、语言...
答:大致可以这样写 include<stdio.h> include<stdlib.h> struct student{ char num[10],name[10];int cn,eng,math;}; //设置一个学生信息的结构体 main(){ int i,j;FILE *fp; //设置文件指针 struct student stu[10],temp;if((fp=fopen("c:\\data.txt","w"))==NULL) //...

有10个学生,每个学生数据包括学号,姓名,专业,班级,三门课成绩?_百度知 ...
答:要求最高者的成绩并按各种排序输出,如果是文档类型可以通过筛选的形式排列。所以一般来说是选择成绩那一个筛选以后其他会自动排好。

二、实验题目: 有10个学生,每个学生的数据包括学号,姓名,及三门课成绩...
答:include <stdio.h> define N 30 struct student { int n;char name[10];int s;};void main( ){ struct student st[N];int i, k, max;for( i=0; i<N; i++)scanf(“%d %s %d”, &st[i].n, st[i].name, &st[i].s);。。。

C语言实现:某班有10个学生,每个学生包姓名和三门成绩,编写程序,从键盘...
答:include <stdio.h> include <string.h> struct student { char name[100];int a[3];} std[10];int main(){ int i, j;student s;for ( i = 0; i < 10; i++){ scanf("%s %d %d %d",std[i].name, &std[i].a[0], &std[i].a[1], &std[i].a[2]);} for (i =...

C++,从键盘输入10个学生的信息包括学号,姓名,成绩要求按每个学生的...
答:include"stdio.h"#include#defineSIZE10structstudent{charid[20];charname[20];intscore[3];floataverage;}stud[SIZE];voidinput()/*输入学生的信息*/{inti;for(i=0;i<SIZE;i++){printf("第%d个学生的信息:\n",i+1);scanf("%s%s%d%d%d",stud[i].id,stud[i].name,&stud[i].score...

...编写一个成绩统计程序,有10个学生(每个学生包括学号、姓名、数学...
答:using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 解决百度知道问题_学生成绩录入问题 { class Program { static void Main(string[] args){ Console.WriteLine("请输入学生的信息:");Observa...