实验六

布鲁布鲁鲁 布鲁布鲁鲁     2022-11-28     350

关键词:


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 3

  // 运行程序输入测试时,可以把N改小一些输入测试

typedef struct student
int id; /*学生学号 */
char name[20]; /*学生姓名 */
char subject[20]; /*考试科目 */
float perf; /*平时成绩 */
float mid; /* 期中成绩 */
float final; /* 期末成绩 */
float total; /* 总评成绩 */
char level[10]; /* 成绩等级 */
STU;

void input(STU[],int ); /*输入学生信息 */
void calc(STU[],int); /*计算总评和等级 */
int fail(STU[],STU [],int); /*不及格学生统计 */
void sort(STU[],int); /*排序 */
void print(STU[], int); /*输出学生信息*/

int main()
STU st[N],fst[N]; // 数组st记录学生信息,fst记录不及格学生信息
int k; // 用于记录不及格学生个数

printf("录入学生成绩信息:\\n");
input(st,N);

printf("\\n成绩处理...\\n");
calc(st,N);

k = fail(st,fst,N);
sort(st, N);
printf("\\n学生成绩排名情况:\\n");
print(st, N);

printf("\\n不及格学生信息:\\n");
print(fst, k);

return 0;

// 输入学生信息
void input(STU s[],int n)
int i;
for(i=0;i<n;i++)
scanf("%d %s %s %f %f %f",&s[i].id,s[i].name,s[i].subject,&s[i].perf,&s[i].mid,&s[i].final);

// 计算总评和等级
void calc(STU s[],int n)
int i;
for(i=0;i<n;i++)
s[i].total=s[i].perf*0.2+s[i].mid*0.2+s[i].final*0.6;

if(s[i].total>=90)
strcpy(s[i].level,"优"); // 注意:等级是字符型数组,要使用strcpy完成赋值
else if(s[i].total>=80 && s[i].total<90)
strcpy(s[i].level,"良");
else if(s[i].total>=70 && s[i].total<80)
strcpy(s[i].level,"中");
else if(s[i].total>=60 && s[i].total<70)
strcpy(s[i].level,"及格");
else
strcpy(s[i].level,"不及格");

// 不及格学生统计
// 数组s存放的是所有学生信息,数组t存放不及格学生信息,n是数组s中元素个数
// 函数返回值:返回的是不及格人数
int fail(STU s[],STU t[],int n)
int i,k=0;

for(i=0;i<n;i++)
if(s[i].total<60)
t[k++]=s[i];

return k;

// 根据总评成绩对学生记录信息排序
// 使用的是冒泡排序算法
void sort(STU s[],int n)
int i,j;
STU temp;

for(i=0;i<n-1;i++)
for(j=0;j<n-1-i;j++)
if(s[j].total<s[j+1].total)
temp = s[j];
s[j] = s[j+1];
s[j+1] = temp;

// 输出学生信息
void print(STU s[], int n)
int i;

printf("-----------------\\n");
printf("学号 姓名 考试科目 平时成绩 期中成绩 期末成绩 总评成绩 成绩等级\\n");
for(i=0;i<n;i++)
printf("%5d %10s%20s %5.1f %5.1f %5.1f %5.1f %10s\\n",s[i].id,s[i].name,s[i].subject,s[i].perf,s[i].mid,s[i].final,s[i].total,s[i].level);

 

 

 

#include <stdio.h>

const int N=5;

// 定义结构体类型struct student,并定义STU为其别名
typedef struct student
long no;
char name[20];
int score;
STU;

// 函数声明
void input(STU s[], int n);
int findMinlist(STU s[], STU t[], int n);
void output(STU s[], int n);

int main()
STU stu[N], minlist[N];
int count;

printf("录入%d个学生信息\\n", N);
input(stu, N);

printf("\\n统计最低分人数和学生信息...\\n");
count = findMinlist(stu, minlist, N);

printf("\\n一共有%d个最低分,信息如下:\\n", count);
output(minlist, count);

return 0;

// 输入n个学生信息,存放在结构体数组s中
void input(STU s[], int n)
int i;
for(i=0; i<n; i++)
scanf("%ld %s %d", &s[i].no, s[i].name, &s[i].score);

// 输出结构体s中n个元素信息
void output(STU s[], int n)
int i;
for(i=0; i<n; i++)
printf("%ld %s %d\\n", s[i].no, s[i].name, s[i].score);

// 在结构体数组s中,查找最低分学生的记录,将其存入结构体数组t中
// 形参n是结构体数组s中元素个数
// 函数返回最低分的学生人数
int findMinlist(STU s[], STU t[], int n)
int min=s[0].score,j=0;
for(int i=0;i<n;i++)
if(s[i].score<min)
min=s[i].score;

for(int i=0;i<n;i++)
if(s[i].score==min)
t[j++]=s[i];

return j;

 

 

 

#include <stdio.h>
#include <string.h>
const int N = 5;

// 定义结构体类型struct student,并定义其别名为STU
typedef struct student
long int id;
char name[20];
float objective; /*客观题得分*/
float subjective; /*操作题得分*/
float sum;
char level[10];
STU;

// 函数声明
void input(STU s[], int n);
void output(STU s[], int n);
void process(STU s[], int n);

int main()
STU stu[N];

printf("录入%d个考生信息: 准考证号,姓名,客观题得分(<=40),操作题得分(<=60)\\n", N);
input(stu, N);

printf("\\n对考生信息进行处理: 计算总分,确定等级\\n");
process(stu, N);

printf("\\n打印考生完整信息: 准考证号,姓名,客观题得分,操作题得分,总分,等级\\n");
output(stu, N);

return 0;

// 录入考生信息:准考证号,姓名,客观题得分,操作题得分
void input(STU s[], int n)
int i;
for(i=0;i<n;i++)
scanf("%ld %s %f %f",&s[i].id,s[i].name,&s[i].objective,&s[i].subjective);

//输出考生完整信息: 准考证号,姓名,客观题得分,操作题得分,总分,等级
void output(STU s[], int n)
int i;
for(i=0;i<n;i++)
printf("%22ld %9s %8.1f %10.1f %9.1f %5s\\n",s[i].id,s[i].name,s[i].objective,s[i].subjective,s[i].sum,s[i].level);

// 对考生信息进行处理:计算总分,排序,确定等级
void process(STU s[], int n)
int i,j;
STU temp;
for(i=0;i<n;i++)
s[i].sum=s[i].objective+s[i].subjective;
if(s[i].sum>=90) strcpy(s[i].level,"优");
else if(s[i].sum>=80) strcpy(s[i].level,"良");
else if(s[i].sum>=70) strcpy(s[i].level,"中");
else if(s[i].sum>=60) strcpy(s[i].level,"及格");
else strcpy(s[i].level,"不及格");


for(i=0;i<n-1;i++)
for(j=0;j<n-1-i;j++)
if(s[j].sum<s[j+1].sum)
temp = s[j];
s[j] = s[j+1];
s[j+1] = temp;

 

 

实验六

任务三:defis_valid(x):ls=[str(i)foriinrange(0,10)]ls.append('X')iflen(x)<18:returnFalseforainrange(len(x)):ifx[a]notinls:returnFal 查看详情

实验六(代码片段)

实验六chip类#include<iostream>usingnamespacestd;classbaseprivate:inta,b;public:base(intx,inty):a(x),b(y)intadd()constreturna+b;;classA:publicbaseprivate:inta,b;public:A(intx,inty):base(x,y),a 查看详情

实验六(代码片段)

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465#include<stdio.h>constintN=5;//定义结构体类型structstudent,并定义STU为其别名typedefstru 查看详情

实验六

#include<stdio.h>#include<string.h>#defineN3typedefstructstudent intid; charname[20]; charsubject[20]; floatperf; floatmid; floatfinal; floattotal; charlevel[10];STU;voidcalc(STU[],int); 查看详情

网络攻防_实验六

               查看详情

实验六201771010101白玛次仁

第五章 继承总结实验六继承定义与使用实验时间2018-9-281.类,超类与子类继承Employee类来定义Manager类格式,关键字extends表示继承。Class新类名(子类(subclass),派生类(derivedclass)或孩子类(chideclass))。extends已有类名(超类... 查看详情

实验六信息搜集

实验六信息搜集实验要求2.实践内容(1)各种搜索技巧的应用(2)DNSIP注册信息的查询(3)基本的扫描技术:主机发现、端口扫描、OS及服务版本探测、具体服务的查点(4)漏洞扫描:会扫,会看报告,会查漏洞说明,会修补... 查看详情

实验六

1合并文件,添加语句#include<iostream>#include<fstream>#include<string>#include<cstdlib>usingnamespacestd;intmain()stringfilename;cout<<"输入打开的文件:";cin>>filename;ofstreamfout 查看详情

实验六

#include<stdio.h>#include<stdlib.h>#include<string.h>#defineN3 //运行程序输入测试时,可以把N改小一些输入测试typedefstructstudent intid; /*学生学号*/ charname[20]; /*学生姓名*/ charsubject[20]; /*考试科目*/ 查看详情

实验六(代码片段)

#实验三fromturtleimport*#绘制正方形#参数size指定边长,rgb指定画笔颜色#如果没有给参数,采用默认值defsquare(size=50,rgb=\'orange\'):pencolor(rgb)foriinrange(4):fd(size)left(90)defmain():setup(800,600)speed(0)foriinrange(10):square(80)le 查看详情

实验六

 心得:在此次实验中,我了解到了函数的具体调用过程,但仍然需要继续练习将函数调用掌握。1.函数的定义 2.函数的调用  3.参数传递  4.函数结果返回 5.函数原型声明 #include<stdio.h>#include<mat... 查看详情

实验六(代码片段)

实验任务1#include<stdio.h>#include<stdlib.h>#include<string.h>#defineN3//运行程序输入测试时,可以把N改小一些输入测试typedefstructstudentintid;/*学生学号*/charname[20];/*学生姓名*/charsubject[20];/*考试科目*/floatperf;/ 查看详情

实验六(代码片段)

实验任务1:#include<stdio.h>#include<stdlib.h>#include<string.h>#defineN3//运行程序输入测试时,可以把N改小一些输入测试typedefstructstudentintid;/*学生学号*/charname[20];/*学生姓名*/charsubject[20];/*考试科目*/floatperf; 查看详情

数据结构-实验六排序

实验六  排序 l 实验目的1、排序的基本概念     1.掌握在数组上进行各种排序的方法和算法。     2.深刻理解各种方法的特点,并能灵活应用。     3.加深对排... 查看详情

实验六(代码片段)

 1.验证性实验#include<iostream>#include<fstream>#include<string>#include<cstdlib>usingnamespacestd;intmain()stringfilename1,filename2,newfilename;cout<<"输入要合并的两个文件名:";ci 查看详情

实验六(代码片段)

fromturtleimport*defsquare(size=50,rbg=\'blue\'):pencolor(rbg)foriinrange(4):fd(size)left(90)setup(800,600)speed(0)foriinrange(10):square()left(36)hideturtle()done()fromturtleimport*setup(800,600)penc 查看详情

实验六

1.1#include<stdio.h>#defineN4intmain()intx[N]=1,9,8,4;inti;int*p;//方式1:通过数组名和下标遍历输出数组元素for(i=0;i<N;++i)printf("%d",x[i]); 查看详情

mooc《linux操作系统编程》学习笔记-实验六(代码片段)

实验六线程同步实验https://www.icourse163.org/learn/UESTC-1003040002?tid=1455108444#/learn/content?type=detail&id=1228729539&cid=1245454470实验六 线程同步实验https://www.icourse163.org/learn/UESTC-1003040002?tid=14 查看详情