高世波 1 year ago
parent f0650ff07a
commit 71f3a0b2d2

Binary file not shown.

@ -0,0 +1,19 @@
#include "mysyslib.h"
void cancel(ss*stu){
char* tmp = (char*)malloc(sizeof(char)*3);
do{
char*ID = (char*)malloc(sizeof(char)*5);
scanf("%s",ID);
for(int i = 0; i < stu->nums; ++i){
if(strcmp(stu->student[i].id,ID)){
for(int j = i; j < stu->nums-1; ++j){
stu->student[j] = stu->student[j+1];
}
}
}
allPrint(stu);
printf("continue?\n");
scanf("%s",tmp);
}while(strcmp(tmp,"yes"));
}

@ -0,0 +1,18 @@
#include "mysyslib.h"
ss* init(int Nums){
ss* stu = (ss*)malloc(sizeof(ss));
if(!stu) return NULL;
stu->nums = 0;
stu->student = (Student*)malloc(sizeof(Student)*Nums);
if(!stu->student) return NULL;
for(int i = 0; i < Nums; ++i){
stu->student[i].id = (char*)malloc(sizeof(char)*5);
stu->student[i].class = (char*)malloc(sizeof(char)*2);
stu->student[i].name = (char*)malloc(sizeof(char)*10);
}
return stu;
}

@ -0,0 +1,33 @@
#include "mysyslib.h"
void input(ss*stu){
char *tmp = (char*)malloc(sizeof(char)*3);
do{
printf("Id ");
// get
printf("\n");
printf("class ");
// get
printf("\n");
printf("name ");
// get
printf("\n");
printf("score1 ");
// get
printf("\n");
printf("score2 ");
// get
printf("\n");
printf("score3 ");
// get
printf("\n");
printf("continue?\n");
scanf("%s",tmp);
}while(strcmp(tmp,"yes"));
}

@ -2,11 +2,15 @@
int main(){
char ipt;
ss* stu = init(6);
while(1){
ipt = mainMenu();
if(ipt=='i'){
input(stu);
}else if(ipt=='o'){
cancel(stu);
}else if(ipt=='m'){
}else if(ipt=='q'){
break;
}else{

@ -1,3 +1,27 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct{
char *id;
char *class;
char *name;
double score1;
double score2;
double score3;
double score;
}Student;
typedef struct{
Student* student;
int nums;
}ss;
ss* init(int);
char mainMenu();
void getCom(ss*);
void Print(Student*);
void allPrint(ss*);
void input(ss*);
void cancel(ss*);
void Select(ss*);

@ -0,0 +1,11 @@
#include "mysyslib.h"
void Print(Student*student){
printf("%s,%s,%s,%.1lf,%.1lf,%.1lf,%.1lf\n",student->id,student->class,student->name,student-> score1,student->score2,student->score3,student->score);
}
void allPrint(ss*stu){
for(int i = 0; i < stu->nums; ++i){
Print(&stu->student[i]);
}
}

@ -43,7 +43,7 @@ ss* init(int Nums){
ss* stu = (ss*)malloc(sizeof(ss));
if(!stu) return NULL;
stu->nums = Nums;
stu->nums = 0;
stu->student = (Student*)malloc(sizeof(Student)*Nums);
if(!stu->student) return NULL;
Loading…
Cancel
Save