You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
708 lines
15 KiB
708 lines
15 KiB
第1步骤
|
|
#include<stdio.h>
|
|
int main(){
|
|
char ch;
|
|
int i;
|
|
for(i=1;i<=30;i++)
|
|
printf(" ");
|
|
printf("1.Input\n");
|
|
for(i=1;i<=30;i++)
|
|
printf(" ");
|
|
printf("2.Output\n");
|
|
for(i=1;i<=30;i++)
|
|
printf(" ");
|
|
printf("3.Order\n");
|
|
for(i=1;i<=30;i++)
|
|
printf(" ");
|
|
printf("4.Quit\n");
|
|
scanf("%c",&ch);
|
|
if(ch=='i'){
|
|
printf("You are trying to Input info\n");
|
|
}
|
|
else if(ch=='o'){
|
|
printf("You are trying to Onput info\n");
|
|
}
|
|
else if(ch=='m'){
|
|
printf("You are trying to Make things ordered\n");
|
|
}
|
|
else if(ch=='q'){
|
|
printf("You are about to Quit\n");
|
|
}
|
|
else{
|
|
printf("Wrong input");
|
|
}
|
|
}
|
|
第2步骤
|
|
#include<stdio.h>
|
|
int main()
|
|
{
|
|
struct student
|
|
{
|
|
int num;
|
|
float gaoshu;
|
|
float dawu;
|
|
float english;
|
|
float sum;
|
|
}student1, student2, student3;
|
|
printf("输入学生成绩:\n");
|
|
scanf("%d\n%f\n%f\n%f\n", &student1.num, &student1.gaoshu, &student1.dawu, &student1.english);
|
|
scanf("%d\n%f\n%f\n%f\n", &student2.num, &student2.gaoshu, &student2.dawu, &student2.english);
|
|
scanf("%d\n%f\n%f\n%f\n", &student3.num, &student3.gaoshu, &student3.dawu, &student3.english);
|
|
student1.sum = student1.gaoshu + student1.dawu + student1.english;
|
|
student2.sum = student2.gaoshu + student2.dawu + student2.english;
|
|
student3.sum = student3.gaoshu + student3.dawu + student3.english;
|
|
printf("输出学生成绩:\n");
|
|
printf("%d %.1f %.1f %.1f %.1f", student1.num, student1.gaoshu, student1.dawu, student1.english, student1.sum);
|
|
printf("\n");
|
|
printf("%d %.1f %.1f %.1f %.1f", student2.num, student2.gaoshu, student2.dawu, student2.english, student2.sum);
|
|
printf("\n");
|
|
printf("%d %.1f %.1f %.1f %.1f" ,student3.num, student3.gaoshu, student3.dawu, student3.english, student3.sum);
|
|
printf("\n");
|
|
return 0;
|
|
}
|
|
第3步骤
|
|
#include<stdio.h>
|
|
int main(){
|
|
char ch;
|
|
int i;
|
|
for(i=1;i<=30;i++)
|
|
printf(" ");
|
|
printf("1.Input\n");
|
|
for(i=1;i<=30;i++)
|
|
printf(" ");
|
|
printf("2.Output\n");
|
|
for(i=1;i<=30;i++)
|
|
printf(" ");
|
|
printf("3.Order\n");
|
|
for(i=1;i<=30;i++)
|
|
printf(" ");
|
|
printf("4.Quit\n");
|
|
scanf("%c",&ch);
|
|
if(ch=='i'){
|
|
printf("Please input info of the three students:\n");
|
|
}
|
|
else if(ch=='o'){
|
|
printf("You are trying to Onput info\n");
|
|
}
|
|
else if(ch=='m'){
|
|
printf("You are trying to Make things ordered\n");
|
|
}
|
|
else if(ch=='q'){
|
|
printf("You are about to Quit\n");
|
|
}
|
|
else{
|
|
printf("Wrong input");
|
|
}
|
|
struct student{
|
|
int num;
|
|
float math;
|
|
float phy;
|
|
float eng;
|
|
}stu[3];
|
|
for(i=0;i<3;i++){
|
|
scanf("%d%f%f%f",&stu[i].num,&stu[i].math,&stu[i].phy,&stu[i].eng);
|
|
}
|
|
float sum[3],aver[3];
|
|
for(i=0;i<3;i++){
|
|
sum[i]=stu[i].math+stu[i].phy+stu[i].eng;
|
|
aver[i]=sum[i]/3;
|
|
}
|
|
float n[3];
|
|
int j;
|
|
n[0]=(sum[0]>sum[1]?sum[0]:sum[1]);
|
|
n[0]=(n[0]>sum[2]?n[0]:sum[2]);
|
|
if(n[0]==sum[0]){
|
|
if(sum[1]>sum[2])
|
|
{n[1]=sum[1];
|
|
n[2]=sum[2];
|
|
}
|
|
else if(sum[2]>sum[1]){
|
|
n[1]=sum[2];
|
|
n[2]=sum[1];
|
|
}
|
|
}
|
|
else if(n[0]==sum[1]){
|
|
if(sum[0]>sum[2]){
|
|
n[1]=sum[0];
|
|
n[2]=sum[2];
|
|
}
|
|
else if(sum[2]>sum[0]){
|
|
n[1]=sum[2];
|
|
n[2]=sum[0];
|
|
}
|
|
}
|
|
else if(n[0]==sum[2]){
|
|
if(sum[0]>sum[1]){
|
|
n[1]=sum[0];
|
|
n[2]=sum[1];
|
|
}
|
|
else if(sum[1]>sum[0]){
|
|
n[1]=sum[1];
|
|
n[2]=sum[0];
|
|
}
|
|
}
|
|
for(i=2;i>=0;i--){
|
|
for(j=0;j<3;j++){
|
|
if(n[i]==sum[j])
|
|
printf("%d,%.1f,%.1f\n",stu[j].num,sum[j],aver[j]);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
第4步骤
|
|
#include<stdio.h>
|
|
#include<string.h>
|
|
typedef struct {
|
|
char sid[10];
|
|
int class;
|
|
float score[3];
|
|
float totalScore;
|
|
} Student;
|
|
void insertStudent(Student students[], int size, Student newStudent) {
|
|
students[size] = newStudent;
|
|
for (int i = 0; i < size; i++) {
|
|
for (int j = i + 1; j <= size; j++) {
|
|
if (students[i].class > students[j].class || (students[i].class == students[j].class && students[i].totalScore < students[j].totalScore)) {
|
|
Student temp = students[i];
|
|
students[i] = students[j];
|
|
students[j] = temp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void printStudents(Student students[], int size,char insert[]) {
|
|
char m;
|
|
for (int i = 0; i < size; i++) {
|
|
if(strcmp(students[i].sid,insert)==0)
|
|
{
|
|
printf(" %s %d %.1f %.1f %.1f %.1f insert\n", students[i].sid, students[i].class, students[i].score[0], students[i].score[1], students[i].score[2], students[i].totalScore);
|
|
}
|
|
else
|
|
{
|
|
printf(" %s %d %.1f %.1f %.1f %.1f\n", students[i].sid, students[i].class, students[i].score[0], students[i].score[1], students[i].score[2], students[i].totalScore);
|
|
}
|
|
}
|
|
}
|
|
int main() {
|
|
Student students[4] = {
|
|
{"1001", 11, {99.5,88.5,89.5}, 277.5},
|
|
{"1002", 12, {77.9,56.5,87.5}, 221.9},
|
|
{"1003", 11, {92.5,99.0,60.5}, 252.0}
|
|
};
|
|
int size = 3;
|
|
char insert[10];
|
|
Student newStudent;
|
|
printf("请输入新学生信息:\n");
|
|
printf("学号:");
|
|
scanf("%s\n", newStudent.sid);
|
|
printf("班级:");
|
|
scanf("%d\n", &newStudent.class);
|
|
printf("三门课程成绩:");
|
|
scanf("%f\n %f\n %f\n", &newStudent.score[0], &newStudent.score[1], &newStudent.score[2]);
|
|
strcpy(insert,newStudent.sid);
|
|
newStudent.totalScore = newStudent.score[0] + newStudent.score[1] + newStudent.score[2];
|
|
insertStudent(students, size, newStudent);
|
|
size++;
|
|
printf("所有学生信息如下:\n");
|
|
printStudents(students, size,insert);
|
|
return 0;
|
|
}
|
|
第5步骤
|
|
#include<stdio.h>
|
|
#include<string.h>
|
|
#define N 3
|
|
struct stu_info
|
|
{
|
|
char num[20];
|
|
int cls,flag;
|
|
char name[20];
|
|
float math,physics,english,total;
|
|
}stu[N]={"10001",11,1,"Zhang",99.5,88.5,89.5,0,"10002",12,1,"Yang",77.9,56.5,87.5,0,"10003",11,1,"Liang",92.5,99.0,60.5,0};
|
|
void del(struct stu_info stu[],const char key[])
|
|
{
|
|
int i,exist=0,j;
|
|
struct stu_info t;
|
|
for(i=0;i<N;i++)
|
|
stu[i].total=stu[i].math+stu[i].physics+stu[i].english;
|
|
for(i=0;i<(N-1);i++){
|
|
for(j=i+1;j<N;j++){
|
|
if(stu[j].total>=stu[i].total)
|
|
{t=stu[i];
|
|
stu[i]=stu[j];
|
|
stu[j]=t;
|
|
}
|
|
}
|
|
}
|
|
for (i=0;i<N;i++)
|
|
{
|
|
if((strcmp((stu+i)->num,key)==0)||(strcmp((stu+i)->name,key)==0))
|
|
{
|
|
stu[i].flag=0;
|
|
exist=1;
|
|
}
|
|
}
|
|
int a;
|
|
if(exist){
|
|
for(a=11;a<=12;a++){
|
|
for(i=0;i<N;i++){
|
|
if(stu[i].flag&&stu[i].cls==a)
|
|
printf("%s %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
|
}
|
|
}
|
|
}
|
|
else if(!exist){
|
|
for(i=0;i<N;i++)
|
|
printf("%s %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
|
}
|
|
|
|
printf("Are you sure(yes/no)?\n");
|
|
char ch2;
|
|
scanf("%c",&ch2);
|
|
if(ch2=='y'){
|
|
return;
|
|
}
|
|
else if(ch2=='n'){
|
|
for(i=0;i<N;i++)
|
|
printf("%s %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
char key[20];
|
|
gets(key);
|
|
del(stu,key);
|
|
return 0;
|
|
}
|
|
第6步骤
|
|
#include<stdio.h>
|
|
#include<string.h>
|
|
#define N 3
|
|
|
|
struct stu_info
|
|
{
|
|
char num[20];
|
|
int cls,flag;
|
|
char name[20];
|
|
float math,physics,english;
|
|
};
|
|
|
|
struct stu_info stu[N]={{"10001",11,0,"Zhang",99.5,88.5,89.5},
|
|
{"10002",12,0,"Yang",77.9,56.5,87.5},
|
|
{"10003",11,0,"Liang",92.5,99.0,60.5}};
|
|
|
|
void sort(struct stu_info *stu,int n)
|
|
{
|
|
int i,j;
|
|
struct stu_info tmp;
|
|
for(i=0;i<n;i++)
|
|
{
|
|
for(j=0;j<n-i-1;j++)
|
|
{
|
|
if(((stu+j)->cls>(stu+j+1)->cls)||((stu+j)->cls==(stu+j+1)->cls)&&((stu+j)->num>(stu+j+1)->num))
|
|
{
|
|
tmp = *(stu+j);
|
|
*(stu+j) = *(stu+j+1);
|
|
*(stu+j+1) = tmp;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
struct stu_info mod;
|
|
scanf("%s",&mod.num);
|
|
scanf("%d",&mod.cls);
|
|
scanf("%s",&mod.name);
|
|
scanf("%f",&mod.math);
|
|
scanf("%f",&mod.physics);
|
|
scanf("%f",&mod.english);
|
|
int i;
|
|
for(i=0;i<N;i++)
|
|
{
|
|
if(strcmp(stu[i].num,mod.num)==0)
|
|
{
|
|
*(stu+i)=mod;
|
|
}
|
|
}
|
|
sort(stu,N);
|
|
for(i=0;i<N;i++)
|
|
{
|
|
if(i==0||stu[i].cls!=stu[i-1].cls) printf("%2d ",stu[i].cls);
|
|
else printf(" ");
|
|
printf("%s %s %.1f %.1f %.1f",stu[i].num,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
|
if(stu[i].flag) printf(" modified");
|
|
printf("\n");
|
|
}
|
|
return 0;
|
|
}
|
|
第7步骤
|
|
#include<stdio.h>
|
|
#include<string.h>
|
|
struct student{
|
|
int id;
|
|
int class;
|
|
char name[20];
|
|
double score1;
|
|
double score2;
|
|
double score3;
|
|
double score;
|
|
}stu[7]={10001,11,"Log",99.5,88.5,89.5,0,10002,12,"Yang",77.9,56.5,87.5,0,10003,11,"Liang",92.5,99.0,60.5,0,10004,11,"Cai",89.6,56.9,90.5,0,10005,14,"Fu",55.6,67.9,98.9,0,10006,12,"Mao",22.1,45.9,99.2,0,10007,13,"Zhan",35.6,67.9,88.0,0};
|
|
int main(){
|
|
void solve1(void);
|
|
void solve2(void);
|
|
void solve3(void);
|
|
void solve4(void);
|
|
void solve5(void);
|
|
int i,j;
|
|
for(i=0;i<7;i++){
|
|
stu[i].score=stu[i].score1+stu[i].score2+stu[i].score3;
|
|
}
|
|
scanf("%d",&j);
|
|
if(j==1){
|
|
solve1();
|
|
}
|
|
else if(j==2){
|
|
solve2();
|
|
}
|
|
else if(j==3){
|
|
solve3();
|
|
}
|
|
else if(j==4){
|
|
solve4();
|
|
}
|
|
else if(j==5){
|
|
solve5();
|
|
}
|
|
return 0;
|
|
}
|
|
void solve1(void){
|
|
int i,j,l,k=0,a,b,c,d;
|
|
double *p;
|
|
double *score[7];
|
|
int *class[7];
|
|
scanf("%d%d",&a,&b);
|
|
for(c=a;c<=b;c++){
|
|
k=0;
|
|
for(i=0;i<7;i++){
|
|
if(stu[i].class==c){
|
|
score[k++]=&stu[i].score;
|
|
}
|
|
if(k==0);
|
|
continue;
|
|
}
|
|
for(j=0;j<(k-1);j++){
|
|
for(l=j+1;l<k;l++){
|
|
if(*score[l]>*score[j])
|
|
{
|
|
p=score[j];
|
|
score[j]=score[l];
|
|
score[l]=p;
|
|
}
|
|
else
|
|
continue;
|
|
}
|
|
}
|
|
for(i=0;i<k;i++){
|
|
for(j=0;j<7;j++){
|
|
if(*score[i]==stu[j].score){
|
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[j].id,stu[j].class,stu[j].name,stu[j].score1,stu[j].score2,stu[j].score3);
|
|
}
|
|
else
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void solve2(void){
|
|
int i,j,k=0,l,a,b,c,d;
|
|
scanf("%d%d",&a,&b);
|
|
double *score[7];
|
|
double *p;
|
|
for(i=11;i<=14;i++){
|
|
k=0;
|
|
for(j=0;j<7;j++){
|
|
if(stu[j].class==i&&(stu[j].id>=a&&stu[j].id<=b)){
|
|
score[k++]=&stu[j].score;
|
|
}
|
|
}
|
|
for(j=0;j<(k-1);j++){
|
|
for(l=j+1;l<k;l++){
|
|
if(*score[l]>*score[j]){
|
|
p=score[j];
|
|
score[j]=score[l];
|
|
score[l]=p;
|
|
}
|
|
}
|
|
}
|
|
for(c=0;c<k;c++){
|
|
for(d=0;d<7;d++){
|
|
if(stu[d].score==*score[c])
|
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[d].id,stu[d].class,stu[d].name,stu[d].score1,stu[d].score2,stu[d].score3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void solve3(void){
|
|
char ch[20]={'\0'};
|
|
int i,j,k=0,l,a,b,c;
|
|
char ch1;
|
|
scanf("%c",&ch1);
|
|
gets(ch);
|
|
int len,label=1;
|
|
double *score[7],*p;
|
|
len=strlen(ch);
|
|
for(i=0;i<7;i++){
|
|
label=1;
|
|
for(j=0;j<(len-1);j++){
|
|
if(stu[i].name[j]!=ch[j])
|
|
{
|
|
label=0;
|
|
break;
|
|
}
|
|
}
|
|
if(label==1)
|
|
score[k++]=&stu[i].score;
|
|
}
|
|
for(i=0;i<(k-1);i++){
|
|
for(j=i+1;j<k;j++){
|
|
if(*score[j]>=*score[i]){
|
|
p=score[i];
|
|
score[i]=score[j];
|
|
score[j]=p;
|
|
}
|
|
}
|
|
}
|
|
for(i=11;i<=14;i++){
|
|
for(j=0;j<k;j++){
|
|
for(l=0;l<7;l++){
|
|
if(stu[l].class==i&&stu[l].score==*score[j])
|
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[l].id,stu[l].class,stu[l].name,stu[l].score1,stu[l].score2,stu[l].score3);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
void solve4(void){
|
|
int i,j,k,l,a,b,c,d;
|
|
double *score[7],*p;
|
|
for(i=0;i<7;i++){
|
|
score[i]=&stu[i].score;
|
|
}
|
|
for(i=0;i<6;i++){
|
|
for(j=i+1;j<7;j++){
|
|
if(*score[j]>=*score[i]){
|
|
p=score[i];
|
|
score[i]=score[j];
|
|
score[j]=p;
|
|
}
|
|
}
|
|
}
|
|
for(i=11;i<=14;i++){
|
|
for(j=0;j<7;j++){
|
|
for(l=0;l<7;l++){
|
|
if(stu[l].class==i&&*score[j]==stu[l].score&&stu[l].score>=98.0)
|
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[l].id,stu[l].class,stu[l].name,stu[l].score1,stu[l].score2,stu[l].score3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void solve5(void){
|
|
int i,j,k=0,l,a,b,c,d=0;
|
|
double *score[7]={NULL},*p;
|
|
char ch1,ch2;
|
|
scanf("%d%d%d",&a,&b,&c);
|
|
for(i=0;i<7;i++){
|
|
if(stu[i].class==a&&(stu[i].id>=b&&stu[i].id<=c)){
|
|
score[k++]=&stu[i].score;
|
|
}
|
|
}
|
|
|
|
for(i=0;i<(k-1);i++){
|
|
for(j=i+1;j<k;j++){
|
|
if(*score[j]>=*score[i]){
|
|
p=score[i];
|
|
score[i]=score[j];
|
|
score[j]=p;
|
|
}
|
|
}
|
|
}
|
|
for(j=0;j<k;j++){
|
|
for(l=0;l<7;l++){
|
|
if(stu[l].class==a&&stu[l].score==*score[j])
|
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[l].id,stu[l].class,stu[l].name,stu[l].score1,stu[l].score2,stu[l].score3);
|
|
}
|
|
}
|
|
}
|
|
第8步骤
|
|
#include<stdio.h>
|
|
struct student{
|
|
int id;
|
|
int class;
|
|
char name[20];
|
|
double score1;
|
|
double score2;
|
|
double score3;
|
|
double score;
|
|
}stu[7];
|
|
void xunwen(void){
|
|
printf("1.input\n");
|
|
printf("2.delet\n");
|
|
printf("3.select\n");
|
|
printf("4.order\n");
|
|
printf("5.output\n");
|
|
printf("6.quit\n");
|
|
printf("please input your option\n");
|
|
}
|
|
void input(void){
|
|
int i,j;
|
|
char str[3];
|
|
void zhixing(void);
|
|
for(i=0;i<7;i++){
|
|
printf("id ");
|
|
scanf("%d",&stu[i].id);
|
|
printf("class ");
|
|
scanf("%d",&stu[i].class);
|
|
printf("name ");
|
|
scanf("%s",stu[i].name);
|
|
printf("score1 ");
|
|
scanf("%lf",&stu[i].score1);
|
|
printf("score2 ");
|
|
scanf("%lf",&stu[i].score2);
|
|
printf("score3 ");
|
|
scanf("%lf",&stu[i].score3);
|
|
printf("continue?\n");
|
|
scanf("%s",str);
|
|
if(str[0]=='y')
|
|
continue;
|
|
else if(str[0]=='n')
|
|
break;
|
|
}
|
|
for(i=0;i<7;i++){
|
|
stu[i].score=stu[i].score1+stu[i].score2+stu[i].score3;
|
|
}
|
|
xunwen();
|
|
zhixing();
|
|
}
|
|
void delet(struct student stu4[]){
|
|
void xunwen(void);
|
|
void zhixing(void);
|
|
int i,j,k,a,b,c;
|
|
char str[3];
|
|
scanf("%d",&a);
|
|
for(i=0;i<7;i++){
|
|
if(stu[i].id==a){
|
|
stu[i].id=0;
|
|
}
|
|
}
|
|
for(i=0;i<7;i++){
|
|
if(stu[i].id!=0)
|
|
printf("%d %d %s %.1f %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score);
|
|
}
|
|
printf("continue?\n");
|
|
struct student *p=stu;
|
|
scanf("%s",str);
|
|
if(str[0]=='y')
|
|
delet(p);
|
|
else if(str[0]=='n')
|
|
xunwen();
|
|
zhixing();
|
|
}
|
|
void select(struct student stu7[]){
|
|
void xunwen(void);
|
|
void zhixing(void);
|
|
int i,j,k,a,b,c=1;
|
|
char str[3];
|
|
scanf("%d",&a);
|
|
if(a>100){
|
|
for(i=0;i<7;i++){
|
|
if(stu7[i].id==a)
|
|
printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score);
|
|
c=0;
|
|
}
|
|
}
|
|
else if(a<100){
|
|
for(i=0;i<7;i++){
|
|
if(stu7[i].class==a){
|
|
printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score);
|
|
c=0;
|
|
}
|
|
}
|
|
}
|
|
if(c==1)
|
|
printf("there is no eligible student");
|
|
printf("continue?\n");
|
|
struct student *p=stu;
|
|
scanf("%s",str);
|
|
if(str[0]=='y'){
|
|
select(p);
|
|
}
|
|
else if(str[0]=='n'){
|
|
xunwen();
|
|
zhixing();
|
|
}
|
|
}
|
|
void order(struct student stu2[]){
|
|
void zhixing(void);
|
|
void output(void);
|
|
int i,j,k=0,a,b,c;
|
|
struct student temp;
|
|
struct student stu1[7];
|
|
for(i=0;i<7;i++){
|
|
stu1[i]=stu2[i];
|
|
}
|
|
for(i=0;i<6;i++){
|
|
for(j=i+1;j<7;j++){
|
|
if(stu1[j].score>=stu1[i].score){
|
|
temp=stu1[i];
|
|
stu1[i]=stu1[j];
|
|
stu1[j]=temp;
|
|
}
|
|
}
|
|
}
|
|
for(i=1;i<30;i++){
|
|
for(j=0;j<7;j++){
|
|
if(stu1[j].class==i)
|
|
stu2[k++]=stu1[j];
|
|
}
|
|
}
|
|
for(i=0;i<7;i++){
|
|
if(stu[i].id!=0)
|
|
printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score);
|
|
}
|
|
xunwen();
|
|
zhixing();
|
|
}
|
|
void output(){
|
|
void zhixing(void);
|
|
int i;
|
|
for(i=0;i<7;i++){
|
|
if(stu[i].id!=0)
|
|
printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score);
|
|
}
|
|
xunwen();
|
|
zhixing();
|
|
}
|
|
void quit(void){
|
|
return;
|
|
}
|
|
void zhixing(void){
|
|
int i;
|
|
scanf("%d",&i);
|
|
struct student *p=stu;
|
|
switch(i){
|
|
case 1:input();break;
|
|
case 2:delet(p);break;
|
|
case 3:select(p);break;
|
|
case 4:order(p);break;
|
|
case 5:output();break;
|
|
case 6:quit();break;
|
|
}
|
|
}
|
|
int main(){
|
|
xunwen();
|
|
zhixing();
|
|
return 0;
|
|
} |