关键词:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 #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中,查找最低分学生的记录,将其存入结构体数组s中 // 形参n是结构体数组s中元素个数 // 函数返回最低分的学生人数 int findMinlist(STU s[], STU t[], int n) // 补足函数实现 // ××× int i,k=0; int temp=s[0].score; for(i=1;i<n;i++) if(s[i].score<temp) temp=s[i].score; for(i=0;i<n;i++) if(s[i].score==temp) t[k++]=s[i]; return k;
#include <stdio.h> #include <string.h> const int N = 10; // 定义结构体类型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("%ld %s %.2f %.2f %.2f %s\\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,k; STU temp; for(i=0;i<n;i++) s[i].sum=s[i].subjective+s[i].objective; for(j=0;j<n-1;j++) for(k=0;k<n-j-1;k++) if(s[k].sum<s[k+1].sum) temp=s[k];s[k]=s[k+1];s[k+1]=temp; i=0; for(i=0;i<n;i++) if(i==0) strcpy(s[i].level,"优秀"); else if(i>=1&&i<=4) strcpy(s[i].level,"合格"); else if(i>=5&&i<=9) strcpy(s[i].level,"不合格");
实验六(代码片段)
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 查看详情
实验六(代码片段)
#实验三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 查看详情
实验六(代码片段)
Part1#include<stdio.h>constintN=5;typedefstructstudentlongno;charname[20];intscore;STU;voidinput(STUs[],intn);intfindMinlist(STUs[],STUt[],intn);voidoutput(STUs[],intn);intmain()STUstu[N],min 查看详情
实验六(代码片段)
part1#include<stdio.h>constintN=5;typedefstructstudentlongno;charname[20];intscore;STU;voidinput(STUs[],intn);intfindMinlist(STUs[],STUt[],intn);voidoutput(STUs[],intn);intmain()STUstu[N],min 查看详情
实验六(代码片段)
实验任务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; 查看详情
实验六(代码片段)
part1结构体类型与编程应用#include<stdio.h>constintN=5;typedefstructstudentlongno;charname[20];intscore;STU;voidinput(STUs[],intn);intfindminlist(STUs[],STUt[],intn);voidoutput(STUs[],intn);intmain()STU 查看详情
实验六(代码片段)
1.验证性实验#include<iostream>#include<fstream>#include<string>#include<cstdlib>usingnamespacestd;intmain()stringfilename1,filename2,newfilename;cout<<"输入要合并的两个文件名:";ci 查看详情
实验六(代码片段)
part1.#include<stdio.h>constintN=5;//定义结构体类型structstudent,并定义STU为其别名typedefstructstudentlongno;charname[20];intscore;STU;//函数声明voidinput(STUs[],intn);intfindMinlist(STUs[],STUt[],intn);voidout 查看详情
实验六(代码片段)
part1.#include<stdio.h>constintN=5;//定义结构体类型structstudent,并定义STU为其别名typedefstructstudent longno; charname[20]; intscore; STU;//函数声明voidinput(STUs[],intn);intfindMinlist(STUs[],STUt[],intn);voi 查看详情
实验六(代码片段)
fromturtleimport*defsquare(size=50,rgb=\'orange\'):pencolor(rgb)foriinrange(4):fd(size)left(90)defmain():setup(800,600)speed(0)foriinrange(10):square(80)right(36)hideturtle()done()if__name__==\'__main 查看详情
实验六(代码片段)
part1ex1constintN=5;//定义结构体类型structstudent,并定义STU为其别名typedefstructstudentlongno;charname[20];intscore;STU;//函数声明voidinput(STUs[],intn);intfindMinlist(STUs[],STUt[],intn);voidoutput(STUs[],intn);intm 查看详情
实验六(代码片段)
part1:补足程序1:补足程序如下:#include<stdio.h>constintN=5;//定义结构体类型structstudent,并定义STU为其别名typedefstructstudentlongno;charname[20];intscore;STU;//函数声明voidinput(STUs[],intn);intfindMinlist(STUs[],STUt[], 查看详情
实验六(代码片段)
一,ex1-2#include<stdio.h>constintN=5;//定义结构体类型structstudent,并定义STU为其别名typedefstructstudentlongno;charname[20];intscore;STU;//函数声明voidinput(STUs[],intn);intfindMinlist(STUs[],STUt[],intn);voidou 查看详情
实验六(代码片段)
fromturtleimport*defsquare(size=50,rgb=\'orange\'):pencolor(rgb)foriinrange(4):fd(size)left(90)defmain():setup(800,600)speed(0)foriinrange(10):square(80)left(36)hideturtle()done()if__name__==\'__main_ 查看详情
实验六(代码片段)
#include<stdio.h>#include<stdlib.h>#include<string.h>#defineN4typedefstructstudentintid;/*学生学号*/charname[20];/*学生姓名*/charsubject[20];/*考试科目*/floatperf;/*平时成绩*/floatmid;/*期中成绩*/float 查看详情
实验六(代码片段)
验证性实验基础练习#include<iostream>#include<fstream>usingnamespacestd;intmain()ofstreama("3.txt",ios_base::app);if(!"3.txt")cout<<"failtoopen"<<endl;return1;a<<‘\\n‘<<"m 查看详情
实验六(代码片段)
defmain():passtask3fromturtleimport*defsquare(size=50,rgb=\'black\'):pencolor(rgb)foriinrange(4):fd(size)left(90)foriinrange(11):square(80)left(360/11)hideturtle()done()if__name__==\'__main__\':main() 查看详情