1. 程式人生 > >實訓室管理系統

實訓室管理系統

數組 結構 調用 {} 之前 ole log ret hello

  1 /*
  2  ============================================================================
  3  Name        : 實訓室管理系統.c
  4  Author      : 徐景祥
  5  Version     :
  6  Copyright   : All Right Restent
  7  Description : Hello World in C, Ansi-style
  8  ============================================================================
9 */ 10 11 #include <stdio.h> 12 #include <stdlib.h> 13 #define SECRET 123456 14 //申請人結構體 15 struct applyer 16 { 17 int number;//學號 18 int class;//班級 19 char name[20];//名字 20 int class_num;//實訓室編號 21 }; 22 23 struct applyer all_applyer[100] = {};//保存申請人的信息 24 int main(void) 25 { 26
printf(); 27 puts("\ 28 \n ****** ****** 29 \n ********** ********** 30 \n ************* ************* 31 \n ***************************** 32 \n ***************************** 33 \n ****!!!【歡迎進入實訓室管理系統】!!!** 34 \n ***************************
35 \n *********************** 36 \n ******************* 37 \n *************** 38 \n *********** 39 \n ******* 40 \n *** 41 \n *"); 42 puts("--------------------------------------------------------------------"); 43 init_role(); //函數調用 44 return EXIT_SUCCESS; 45 } 46 /*選擇系統登陸角色*/ 47 //1、判斷是申請者還是管理員 48 //2、申請者 :請輸入您的名字、請選擇你要申請的實訓室:1號、2號、 選擇過後提示申請成功 49 //3、管理員:需要輸入密碼,則需要判斷密碼是否正確 50 51 void init_role() 52 { 53 puts("請輸入您登陸的身份(0代表申請者,1代表管理員):"); 54 fflush(stdout);//刷新緩沖區,用戶輸入信息之前必要的步驟 55 int role = 0; 56 scanf("%d",&role); //或者登陸身份0或1 或其他 三種情況 57 if(role == 0) 58 { 59 //申請者 60 61 62 puts("請輸入您的學號、班級、姓名(空格隔開):"); 63 fflush(stdout);//刷新緩沖區,用戶輸入信息之前必要的步驟 64 struct applyer applyer_;// 65 scanf("%d%d%s",&applyer_.number,&applyer_.class,&applyer_.name); 66 puts("請選擇要申請的實訓室編號(1、2、3):"); 67 fflush(stdout);//刷新緩沖區,用戶輸入信息之前必要的步驟 68 int class_num = 1; 69 scanf("%d",&class_num); 70 if(class_num >= 1 && class_num<=3) 71 { 72 //保存信息給管理員看 73 applyer_.class_num=class_num;//把接受到的實訓室編號賦值給結構體裏面 74 save_applyer(applyer_);// 75 puts("恭喜恭喜,申請成功!等待管理員審核....."); 76 return;//函數結束 77 } 78 79 } 80 else if(role == 1)//當輸入1時,管理員 81 { 82 83 puts("請輸入管理密碼(8位以內數字):");//提示需要輸入密碼 84 fflush(stdout);//刷新緩沖區,用戶輸入信息之前必要的步驟 85 int secret = 0; 86 scanf("%d",&secret);//獲取輸入的密碼 87 if(secret == SECRET)//判斷輸入的密碼是否與正確的密碼一致 88 { 89 //密碼正確 90 puts("管理員你好!你好漂亮"); 91 } 92 else 93 { 94 puts("您的輸入有誤,請重新輸入!");//密碼錯誤時的提示 95 } 96 } 97 else{ 98 puts("您輸入有誤!"); 99 } 100 101 } 102 /*保存申請人到數組裏面*/ 103 104 void save_applayer(struct applayer aply) 105 { 106 int i; 107 for(i=0;i<100;i++) 108 { 109 if(all_applyer[i].number == 0) 110 { 111 all_applyer[i] = aply; 112 return; 113 } 114 } 115 }

實訓室管理系統