From 71f3a0b2d2877367ebac8f3bf879767c5cd4318a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E4=B8=96=E6=B3=A2?= <2783626707@qq.com> Date: Sun, 5 Nov 2023 09:41:53 +0800 Subject: [PATCH] merge --- .main2.c.swp | Bin 0 -> 12288 bytes delete.c | 19 +++++++++++++++++++ init.c | 18 ++++++++++++++++++ input.c | 33 +++++++++++++++++++++++++++++++++ main.c | 4 ++++ mysyslib.h | 24 ++++++++++++++++++++++++ output.c | 11 +++++++++++ main_副本2.c => unusemain.c | 2 +- 8 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 .main2.c.swp create mode 100644 delete.c create mode 100644 init.c create mode 100644 input.c create mode 100644 output.c rename main_副本2.c => unusemain.c (99%) diff --git a/.main2.c.swp b/.main2.c.swp new file mode 100644 index 0000000000000000000000000000000000000000..1cf5faeab10b85c33189ab7b86788998d57c0e21 GIT binary patch literal 12288 zcmeI2UuYaf9LJ}v)<#=f6p=zC(+erL>18*&mlW%ze@H_iHmSuBUuw|J?p$ue-tKjG zuM$fv7Fq;F5Q2Ra{~%Zu#Xo4pminL%J}81Og7^m%1g#GhDhdU^GrN1Yxl2O{@gXqF zeeQ05JHOw|d}ro26LQo2kBpAfJ!(I}wT+OM{yfA!AnQ98c5fu1VHktDUK}VI{OJuZ z*SAc!;)jtczS(}&bi5@>Ka~lng;9On^voGHF&Apw!BDLwe56S#AQe~z1?o|`@BS^M zXy{_8cjtD{yYHG@g}^d|R6r^q6_5%@1*8H}0jYpgKq|0S6o_i;$SE{-ebV4_$>+M3 z&*WBqNCl(&Km(ni1N?m_Ay>d3;Ct`|_!zto-UF|K7r-gt zfJra{3_w8_xVD9mAHi4PGPndTf;YfvPyrS=3hn_{H=|DQC3qe@1h#>#pacAK2igU$ zfuF(aU>2z0uiFXv2+V^CFbocW{XhZR0RcaC5b_CF03MhC!{7ke4|3p{O@y2UXMhI| zfgaEW?gO1*6Zq~nLcRePzkRQO;-~xCTEPyk>2W9Xe zD1jc(39jEt$S>e?a2dP<-Ue@hbD#nq2O78+{C*1|pMtYs9F#yG=mwj?70j7$!H3{A z@CtYtJO`%0BsdI)zyn|p;Pb2ttd&dCPT=J`Hg&v^1yMc>d-2m11v7+DT=P#<9GB($ zm6EvSrudufpA;6WVg|i5s@CXUnin@p)pYSgnSAIx$^5dgDZNDm5Y zyIr;OGLDHeryrc}o+jE*Ro;%RUP!TU?p$p+`4 zolMz`gb31Xs2Ir6k>$s9FmYJvRKW0A%uQ$9ji&3LiZ}}KC z@5Fr6TkegP`(n#I`X<^O_k1EwV|)YP=?r-y*#(#zG8(X`9(Zw%5C-HVzZN;ZNB8cf zgG#b7Xj=Qj0fmM>-&`8$y}e9Pq3PbROesU5Y1(L%TGS3*!A>TIx$!(ra(1q;Gj4D) zq&x-3hC~Le^MihsXC$7FoBdDijgaY3)?8*n8c`#i^Xowpuet8il03gGf9+O}*PUo3 zo`b4ikI?6p_ztLkV6$K)u0=HzoB2w74b_Hk#8%>~t3vPCRZQRX^w6^4;u*__GM=^b zICCc#Y|U*OyQs)_%bsBL>=~%lJx+7W`Wwll;|*wa$MI`f-*l&4A_pD8ks-UQ6CNKc zVn?Z~hh0T9+ErOZBj8&jG3x*Np z=Nj5eVLEYaim&gMGbwz9CCxEtY+`Bb9jPIk=2P3^G@4q|?9mLC_CZ*(J%9Hx6jjxgH zy_ob_gJUnzsBXuzT(p=Dp`DI5qgM8jtj%_v={B3=a}&`tyeK^wFf(E{ot~png$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")); +} diff --git a/init.c b/init.c new file mode 100644 index 0000000..80e20eb --- /dev/null +++ b/init.c @@ -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; + } diff --git a/input.c b/input.c new file mode 100644 index 0000000..91cb3e3 --- /dev/null +++ b/input.c @@ -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")); +} diff --git a/main.c b/main.c index 288d6f5..97c7215 100644 --- a/main.c +++ b/main.c @@ -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{ diff --git a/mysyslib.h b/mysyslib.h index 7a37c57..2ab5774 100644 --- a/mysyslib.h +++ b/mysyslib.h @@ -1,3 +1,27 @@ #include +#include +#include +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*); diff --git a/output.c b/output.c new file mode 100644 index 0000000..520970f --- /dev/null +++ b/output.c @@ -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]); + } +} diff --git a/main_副本2.c b/unusemain.c similarity index 99% rename from main_副本2.c rename to unusemain.c index fde4e28..63ab658 100644 --- a/main_副本2.c +++ b/unusemain.c @@ -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;