⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sur_tea_func.c.bak

📁 图书管理系统  给予文件的 可以运行的  在MINGW上运行
💻 BAK
字号:
/* file_name:	sur_tea_func.c
 * author:	wangtiezhen miuliang @ Xidian University
 * description:	
 */
#include<ctype.h>
#include<conio.h>
flag_type tea_close_system(void)
{
	char c = 0;
	printf("do you want to save it?(y, n, c)\n");
	c = getch();
	while(c != EOF && c != 'y' && c != 'n' && c != 'c'){
		printf("you need to print [y]es, [n]o, [c]ancel!\n");
		c = getch();
	}
	if(c == 'y'){
		printf("writing data to file");
		super_write();
		printf("\t\t\t\t..[done]\n");
		return sys_close;
	}else if(c == 'n'){
		printf("You didn't write to the file");
		return sys_close;
	}else{
		return session_ok;
	}
	
} 
flag_type tea_insert_books(void)
{
	int num;
	while(1){
		printf("num?");
		scanf("%d", &num);
		while(getchar() != '\n');
		while(find_book_num(bookbt, num) != NULL){
			printf("this num has been occupid.\n");
			printf("num?");
			if(scanf("%d", &num) != 1){
//				error!
				return session_ok;	
			}
		}
		break;
	}
	char name[20];		
	printf("name?");	if(scanf("%s", name) != 1) return session_ok;
	char writer[20];	
	printf("writer?");	if(scanf("%s", writer) != 1) return session_ok;
	int price;
	printf("price?");	if(scanf("%d", &price) != 1) return session_ok;

	inputbook( num,  name,   writer, price);
	
	return session_ok;
}
flag_type tea_borrow_books(void)
{
	int snum, bnum;
	while(1){
		printf("who want to borrow books?\n");
		scanf("%d", &snum);
		while(getchar() != '\n');
		while(find_stu_num(stubt, snum) == NULL){
			printf("do not have the student.\n");
			printf("who want to borrow books?\n");
			if(scanf("%d", &snum) != 1){
//				error!
				while(getchar() != '\n');
				return session_ok;	
			}
		}
		break;
	}
	while(1){
		printf("he want to borrow which book?\n");
		scanf("%d", &bnum);
		while(getchar() != '\n');
		while(find_book_num(bookbt, bnum) == NULL){
			printf("do not have the book.\n");
			printf("he want to borrow which book?\n");
			if(scanf("%d", &bnum) != 1){
//				error!
				return session_ok;	
			}
		}
		break;
	}
	
	inputbb(bnum, snum);
	return session_ok;
}
flag_type tea_return_books(void)
{
	int snum, bnum;
	while(1){
		printf("who want to return books?\n");
		scanf("%d", &snum);
		while(getchar() != '\n');
		while(find_stu_num(stubt, snum) == NULL){
			printf("do not have the student.\n");
			printf("who want to return books?\n");
			if(scanf("%d", &snum) != 1){
//				error!
				return session_ok;	
			}
		}
		break;
	}
/* Begin:
 * he has borrowed
 */
	if( bb_borrowed(bbbt, snum) == 0){
		printf("he didn't borrowed any books.\n");
		return session_ok;
	}else{
		;
	}
 
/* End:
 * he has borrowed
 */
	while(1){
		printf("he want to return which book?\n");
		if(scanf("%d", &bnum) != 1){
			while(getchar() != '\n');
			return session_ok;
		}
//		printf("%d", bnum);
//		putchar('d');
//		while(getchar() != '\n');
//		putchar('d');
//		while(find_book_num(bookbt, bnum) == NULL){
//			printf("do not have the book.\n");
//			printf("he want to return which book?\n");
//			if(scanf("%d", &bnum) != 1){
////				error!
//				return session_ok;	
//			}
//		}
//		break;
		struct bb* p = find_bb_bnum(bbbt, bnum);
		
		if(p == NULL || p->snum != snum){
			printf("he didn't not borrowed this book.\n");
			continue;
		}else{
			bb_del_value(&bbbt, bnum);
			return session_ok;
		}


	}
	
	
	return session_ok;
}
flag_type tea_del_books(void)
{
	int bnum;
	while(1){
		printf("which book do you want to del?");
		if(scanf("%d", &bnum) != 1){
			while(getchar() != '\n');
			return session_ok;
		}else{
			;
		}
		struct book* p = find_book_num(bookbt, bnum);
		if(p == NULL){
			printf("do not have this book.\n");
			continue;
		}
		
		if(find_bb_bnum(bbbt, bnum) != NULL){
			printf("this one has been borrowed.\n");
			continue;
		}
		
		print_book(p);
		printf("do you really want to del this one?\n");
		while(1){
			char c = getch();
			if(c == 'y'){
				book_del_value(&bookbt, bnum);
				return session_ok;
			}else if(c == 'n'){
				return session_ok;
			}else{
				printf("put y/n/c, please!\n");
				continue;
			}
		}
	}
}
flag_type tea_insert_stu(void)
{
	int num;
	while(1){
		printf("num?");
		scanf("%d", &num);
		while(getchar() != '\n');
		while(find_stu_num(stubt, num) != NULL){
			printf("this num has been occupid.\n");
			printf("num?");
			if(scanf("%d", &num) != 1){
//				error!
				return session_ok;	
			}
		}
		break;
	}
	char name[20];		
	printf("name?");	if(scanf("%s", name) != 1) return session_ok;
	char addr[20];	
	printf("addr?");	if(scanf("%s", addr) != 1) return session_ok;
	int password;
	printf("password?");	if(scanf("%d", &password) != 1) return session_ok;
	int age;
	printf("age?");		if(scanf("%d", &age) != 1) return session_ok;
	
	inputstu(num, password, name, age, addr);
	return session_ok;
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -