/ * Title: New virus crown Registration Form 1, the object of study is human 2, one of the people is a linear table can be represented by 3, the object including name, age, body temperature */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 10 #define OVER -2 #define OK 1 #define ADD 10 typedef struct People{ char ID[20]; char name[10]; float head;//体温 }People; typedef People ElemType; typedef struct SqList{ ElemType *elem; int length; int listsize; }SqList; // initialization typedef int Status; Status InitList(SqList &L) { L.elem = (ElemType *)malloc(MAX * sizeof(ElemType)); if(!L.elem) { printf ( " Application failed \ the n- " ); exit(OVER); } L.length = 0; L.listsize = MAX; return OK; } //添加 Status ListInsert(SqList &L,int i,ElemType e) { if(i < 1 || i > L.length + 1) { printf ( " no such person \ the n- " ); exit(OVER); } if(L.length >= L.listsize) { ElemType *newbase = (ElemType *)realloc(L.elem,(L.listsize + ADD) * sizeof(ElemType)); L.elem = newbase; L.listsize += ADD; } ElemType *q,*p; q = &L.elem[i - 1]; for(p = &L.elem[L.length - 1];p >= q;p --) { *(p + 1) = *p; } *q = e; L.length ++; return OK; } //查询 Status GetElem(SqList L,int i,ElemType &e) { if(i < 1 || i > L.length) { the printf ( " system such person \ n- " ); exit(OVER); } e = L.elem[i - 1]; } //删除 Status ListDelete(SqList &L,int i,ElemType &e) { if(i < 1 || i > L.length) { the printf ( " system such person \ n- " ); exit(OVER); } ElemType *q,*p; e = L.elem[i - 1]; p = &L.elem[i - 1]; for(q = p + 1;q <= &L.elem[L.length - 1];q ++) { *(q - 1) = *q; } L.length --; return OK; } //登陆 int Yan(char User[],char Pass[],char USer[],char PAss[]) { int count = 0; if(strcmp(USer,User) == 0 && strcmp(PAss,Pass) == 0) { count = 1; } return count; } int main () { SqList L; int I; int J; // int NUM; // number of char the User [ 20 is ]; char USER [ 20 is ]; // initialize char PASS [ 20 is ]; // initialize char Pass [ 20 is ]; int K; // Number int Money = 100 ; int TEMP; // position int Choice; ElemType e; i = InitList(L); the printf ( " ********** <<<< new virus crown ************** registration table >>>> \ n- " ); printf ( " Tips: If you enter the wrong user name or password three times the system will automatically exit \ the n- " ); printf ( " The system is a payment system that uses a project $ 10, if we are a new user will send 100 \ the n- " ); the printf ( " Balance:% D \ n- " , Money); printf ( " Please register: \ the n- " ); printf ( " Please enter your user name: " ); scanf("%s",USer); printf ( " Please enter your password: " ); scanf("%s",PAss); printf ( " Congratulations, the registration is successful, began login \ the n- " ); printf ( " Please remember your user name and password for \ the n- " ); system("cls"); the printf ( " ********** <<<< new virus crown ************** registration table >>>> \ n- " ); printf ( " Tips: If you enter the wrong user name or password three times the system will automatically exit \ the n- " ); printf ( " The system is a payment system that uses a project $ 10, if we are a new user will send 100 \ the n- " ); printf("余额:%d\n",money); for(j = 0;j < 3;j ++) { printf ( " Please enter your user name: " ); scanf("%s",User); printf ( " Please enter your password: " ); scanf("%s",Pass); if(Yan(User,Pass,USer,PAss) == 1) { printf ( " Congratulations on your successful login \ the n- " ); if(i == 1) { the printf ( " linear table initialized successfully \ n- " ); printf ( " Because this system can only support a small (1--9) Please enter your personal few people want to store personal information: " ); Scanf ( " % D " , & K); // the printf ( "Please enter basic information about the individual 5 \ n-"); the printf ( " Age \ t name \ t temperature \ n- " ); for (I = . 1 ; I <= K; I ++ ) { scanf("%s %s %f",e.ID,e.name,&e.head); ListInsert(L,i,e); } while(money > 0) { the printf ( " function is as follows: \ n- " ); the printf ( " . 1, view the current status registration table \ n- " ); the printf ( " 2, the registration form insert operation \ n- " ); the printf ( " . 3, to perform the deletion in the registration table \ n- " ); printf ( " 4, exit the system \ the n- " ); printf ( " Please enter your selection: " ); scanf("%d",&choice); money -= 10; switch(choice) { case 1: the printf ( " Age \ t name \ t temperature \ n- " ); for (I = . 1 ; I <= K; I ++ ) { GetElem(L,i,e); printf("%s\t%s\t%.1f\n",e.ID,e.name,e.head); } the printf ( " Balance:% D \ n- " , Money); BREAK ; Case 2 : printf ( " Please enter the location you want to insert: " ); scanf("%d",&temp); printf ( " Age \ t name \ t temperature \ the n- " ); scanf("%s %s %f",e.ID,e.name,&e.head); ListInsert(L,temp,e); k ++; the printf ( " Balance:% D \ n- " , Money); break; case 3: printf ( " Please enter delete position: " ); scanf("%d",&temp); ListDelete(L,temp,e); printf ( " deleted data: \ the n- " ); printf ( " Age \ t name \ t temperature \ the n- " ); printf("%s\t%s\t%.1f\n",e.ID,e.name,e.head); k --; the printf ( " Balance:% D \ n- " , Money); break; case 4: the printf ( " Balance:% D \ n- " , Money); exit(OVER); break; } } printf ( " Please check your balance:% d \ the n- " , Money); printf ( " Project \ the n- " ); the printf ( " . 1, charge 100 yuan \ n- " ); the printf ( " 2, charge 200 yuan \ n- " ); the printf ( " . 3, no money \ n- " ); printf ( " Please enter your selection: " ); scanf("%d",&choice); switch(choice) { case 1: money += 100; break; case 2: money += 200; break; case 3: exit(OVER); break; } /* printf ( "Age \ t name \ t temperature \ n"); for(i = 1;i <= 3;i ++) { GetElem(L,i,e); printf("%s %s %.1f\n",e.ID,e.name,e.head); } scanf("%d",&temp); ListDelete(L,temp,e); printf ( "Age \ t name \ t temperature \ n"); printf("%s %s %.1f\n",e.ID,e.name,e.head);*/ } else { printf ( " application space failed \ the n- " ); printf ( " Please check your balance:% d \ the n- " , Money); } } printf ( " You have% d chances \ the n- " , 3 - J - 1 ); } if(j == 3) { printf ( " enter the wrong three times, forced to withdraw from the system \ the n- " ); exit(OVER); } }