#include<stdio.h>
#include<string.h>
#include<windows.h>
int opt;
int count = 0;
typedef struct node* pointer;
struct node {
char order[20];
char id[20];
char name[20];
char week[20];
char day[20];
char part[20];
char course[20];
char reason[20];
pointer next;
};
typedef pointer lklist;
lklist head;
typedef struct nnode* ppointer;
struct nnode {
char id[20];
char name[20];
char week[20];
int cishu;
ppointer next;
};
typedef ppointer llklist;
typedef struct nodes* pointers;
struct nodes {
char account[20];
char password[20];
char power[20];
pointers lchild, rchild;
};
typedef pointers bitree;
bitree t;
const int maxsize = 100;
typedef struct {
bitree data[maxsize];
int front, rear;
}sqqueue;
bitree level_creat();
int login(char no[20], char pwd[20]);
int administrator();
void classattendance();
void classpeople();
int modifypeople(bitree t);
int deletepeople(bitree t);
int insertpeople();
void levelorder(bitree t);
int committee();
void sta(lklist head, int k);
void all(lklist head);
void modify(lklist head, int k);
int updata(pointer p);
int deletes(lklist head, int k);
int insert(lklist head, int i);
pointer get(lklist head, int i);
int student(char no[20]);
void stuweek();
void weekall();
void data();
void mwlocate(lklist head, char no[20], int week);
void swlocate(lklist head, char name[20], int week);
void walocate(lklist head, int week);
lklist creat();
lklist initlist();
int de_sqqueue(sqqueue* sq, bitree* x);
int empty_sqqueue(sqqueue* sq);
int en_sqqueue(sqqueue* sq, bitree x);
void init_sqqueue(sqqueue* sq);
void bubbleSort(llklist mylist);
//创建二叉树,保存班级成员信息
bitree level_creat() {
char str[20];
pointers Q[100];
int front, rear;
pointers root, s;
root = NULL;
front = rear = 0;
int dept = 1;
FILE* fp6;
if ((fp6 = fopen("用户信息文件.txt", "r")) == NULL) {
printf("用户信息文件不存在\n");
return 0;
}
while (!feof(fp6)) {
s = new nodes;
fscanf(fp6, "%s", str);
strcpy(s->account, str);
fscanf(fp6, "%s", str);
strcpy(s->password, str);
fscanf(fp6, "%s", str);
strcpy(s->power, str);
s->lchild = s->rchild = NULL;
rear++;
Q[rear] = s;
if (rear == 1) {
root = s;
front = 1;
}
else {
if (s && Q[front])
if (rear % 2 == 0)
Q[front]->lchild = s;
else
Q[front]->rchild = s;
if (rear % 2 == 1)
front++;
}
}
fclose(fp6);
return root;
}
void init_sqqueue(sqqueue* sq) {
sq->front = sq->rear = 0;
}
int en_sqqueue(sqqueue* sq, bitree x) {
if ((sq->rear + 1) % maxsize == sq->front) {
printf("队满,不能入队!\n");
return 0;
}
sq->rear = (sq->rear + 1) % maxsize;
sq->data[sq->rear] = x;
return 1;
}
int empty_sqqueue(sqqueue* sq) {
if (sq->rear == sq->front)
return 1;
else
return 0;
}
//出队
int de_sqqueue(sqqueue* sq, bitree* x) {
if (sq->rear == sq->front) {
printf("队空,不能出队!\n");
return 0;
}
sq->front = (sq->front + 1) % maxsize;
*x = sq->data[sq->front];
return 1;
}
lklist initlist() {
pointer head;
head = new node;
head->next = NULL;
return head;
}
lklist creat() {
count = 0;
pointer rear, s;
head = new node;
rear = head;
FILE* fp2;
char str[20];
if ((fp2 = fopen("学生考勤情况.txt", "r")) == NULL) {
printf("学生考勤情况不存在\n");
return 0;
}
while (!feof(fp2)) {
s = new node;
fscanf(fp2, "%s", str);
strcpy(s->order, str);
fscanf(fp2, "%s", str);
strcpy(s->id, str);
fscanf(fp2, "%s", str);
strcpy(s->name, str);
fscanf(fp2, "%s", str);
strcpy(s->week, str);
fscanf(fp2, "%s", str);
strcpy(s->day, str);
fscanf(fp2, "%s", str);
strcpy(s->part, str);
fscanf(fp2, "%s", str);
strcpy(s->course, str);
fscanf(fp2, "%s", str);
strcpy(s->reason, str);
rear->next = s;
rear = s;
count++;
}
rear->next = NULL;
fclose(fp2);
return head;
}
void walocate(lklist head, int week) {
printf("序号\t学号\t姓名\t周数\t星期\t节数\t课程\t原因\n");
int sign = 0;
pointer p;
p = head->next;
char wk[20];
sprintf(wk, "第%d周", week);
while (p != NULL) {
if (strcmp(p->week, wk) == 0) {
printf("%s\t", p->order);
printf("%s\t", p->id);
printf("%s\t", p->name);
printf("%s\t", p->week);
printf("%s\t", p->day);
printf("%s\t", p->part);
printf("%s\t", p->course);
printf("%s\n", p->reason);
sign++;
}
p = p->next;
}
if (sign == 0)
printf("%s无考勤记录\n", wk);
}
void swlocate(lklist head, char name[20], int week) {
printf("序号\t学号\t姓名\t周数\t星期\t节数\t课程\t原因\n");
int sign = 0;
pointer p;
p = head->next;
char wk[20];
sprintf(wk, "第%d周", week);
while (p != NULL) {
if (strcmp(p->week, wk) == 0 && strcmp(p->name, name) == 0) {
printf("%s\t", p->order);
printf("%s\t", p->id);
printf("%s\t", p->name);
printf("%s\t", p->week);
printf("%s\t", p->day);
printf("%s\t", p->part);
printf("%s\t", p->course);
printf("%s\n", p->reason);
sign++;
}
p = p->next;
}
if (sign == 0)
printf("%s%s无考勤记录\n", nam
【学生考勤系统】
于 2022-03-23 16:55:39 首次发布