-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.cpp
More file actions
120 lines (117 loc) · 4.19 KB
/
query.cpp
File metadata and controls
120 lines (117 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#include "student.h"
extern NodeType *head;
void Query(int op){
NodeType *s,*r;
s = head->next;
printf("\n\n\n**********查 询 学 生 住 宿 信 息**********\n");
int sum = 0;
if(op == 1){
printf("\n 请输入要查询学生的学号:");
char sno[10];
scanf("%s",sno);
while(s != NULL){
if(strcmp(s->data.sno,sno) == 0){
if(sum == 0){
printf("Record: 学号 姓名 楼号 房间号 班级名\n");
sum++;
}
printf("%18s%9s%6d%10d%13s\n",s->data.sno,s->data.name,s->data.building,s->data.room,s->data.className);
}
s = s->next;
}
}else if(op == 2){
printf("\n 请输入要查询学生的姓名:");
char name[20];
scanf("%s",name);
while(s != NULL){
if(strcmp(s->data.name,name) == 0){
if(sum == 0){
printf("Record: 学号 姓名 楼号 房间号 班级名\n");
sum++;
}
printf("%18s%9s%6d%10d%13s\n",s->data.sno,s->data.name,s->data.building,s->data.room,s->data.className);
}
s = s->next;
}
}else if(op == 3){
printf("\n 请输入要查询学生的房间号:");
int room;
scanf("%d",&room);
while(s != NULL){
if(s->data.room == room){
if(sum == 0){
printf("Record: 学号 姓名 楼号 房间号 班级名\n");
sum++;
}
printf("%18s%9s%6d%10d%13s\n",s->data.sno,s->data.name,s->data.building,s->data.room,s->data.className);
}
s = s->next;
}
}else{
printf("\n 请输入要查询学生的班级名:");
char className[10];
scanf("%s",className);
while(s != NULL){
if(strcmp(s->data.className,className) == 0){
if(sum == 0){
printf("Record: 学号 姓名 楼号 房间号 班级名\n");
sum++;
}
printf("%18s%9s%6d%10d%13s\n",s->data.sno,s->data.name,s->data.building,s->data.room,s->data.className);
}
s = s->next;
}
}
if(sum == 0){
printf("\n 查无此信息!\n");
}
printf("Press any key to continue...");
getch();
}
void Query_interface(){
while(1){
system("cls");
printf(" ***************************************************************\n");
printf(" * *\n");
printf(" * *\n");
printf(" * 青 岛 理 工 大 学 宿 舍 管 理 系 统 *\n");
printf(" * *\n");
printf(" * *\n");
printf(" * 1. 按学号查询 *\n");
printf(" * 2. 按姓名查询 *\n");
printf(" * 3. 按房间号查询 *\n");
printf(" * 4. 按班级查询 *\n");
printf(" * 0. 结束查询返回上层 *\n");
printf(" ***************************************************************\n");
printf("\n\n\n");
loop1:
printf("\t请输入操作数:");
int op;
scanf("%d",&op);
switch(op){
case 0:
return ;
case 1:
Query(1);
break;
case 2:
Query(2);
break;
case 3:
Query(3);
break;
case 4:
Query(4);
break;
default :
printf("\n*****输入错误,请重新输入!*****\n");
goto loop1;
break;
}
}
}