Example #1
0
/*增加学生信息*/
void add_infor(pUSR_INFOR *phead_infor)
{
	pUSR_INFOR phead, ptail, psearch;
	int usr_id;
	char usr_name[USR_NAME_LEN];
	float usr_score1,usr_score2, usr_score3, usr_score4, usr_score5;
	phead = *phead_infor;
	psearch = *phead_infor;
	while(phead->pNext_Usr_Infor != NULL)
		phead = phead->pNext_Usr_Infor;
	ptail = phead;
	printf("请按 <学号 姓名 分数1 分数2 分数3 分数4 分数5> 的格式输入学生信息:\n");
	scanf("%d%s%f%f%f%f%f",&usr_id,usr_name,&usr_score1,&usr_score2,&usr_score3,&usr_score4,&usr_score5);
	while(psearch != NULL){
		if(psearch->usr_id == usr_id){
			printf("警告:该生已经存在\n");
			return;
		}
		else
			psearch = psearch->pNext_Usr_Infor;
	}
	if(psearch == NULL){
		order_insert(phead_infor, &ptail,usr_id,usr_name,usr_score1,usr_score2,usr_score3,usr_score4,usr_score5);
		printf("Mission Success\n");
	}
}
Example #2
0
/*系统初始化*/
void system_init(const char *config_file_name, pUSR_ACCOUNT *pUsr_Account, pUSR_INFOR *pUsr_Infor)
{
	FILE *fp_account, *fp_infor, *fp_config;
	pUSR_ACCOUNT ptail_account;
	pUSR_INFOR ptail_infor;
	int usr_id;
	float usr_score1, usr_score2, usr_score3, usr_score4, usr_score5;
	char usr_name[USR_NAME_LEN], ch_account[40] = {0}, ch_infor[40] = {0},
		 usr_pwd[USR_PWD_LEN];
	USR_ROLE usr_role;//定义权限:0代表管理员,1代表用户
	ptail_account = NULL;
	ptail_infor = NULL;

	fp_config = fopen(config_file_name, "r+");
	if(fp_config == NULL){
		printf("config.txt open failure");
		return;
	}
	
	fscanf(fp_config, "%s", ch_account);
	fscanf(fp_config, "%s", ch_infor);
	fclose(fp_config);
	fp_account = fopen(ch_account, "r+");
	fp_infor = fopen(ch_infor, "r+");

	while(fscanf(fp_account, "%s%s%d", usr_name, usr_pwd, &usr_role) == 3){
		tail_insert(pUsr_Account, &ptail_account, usr_name, usr_pwd, usr_role);
	}
	while(fscanf(fp_infor, "%d%s%f%f%f%f%f",&usr_id,usr_name,&usr_score1,&usr_score2,&usr_score3,&usr_score4,&usr_score5)== 7){
		order_insert(pUsr_Infor, &ptail_infor,usr_id,usr_name,usr_score1,usr_score2,usr_score3,usr_score4,usr_score5);
	}
}
Example #3
0
void OrderManager::run()
{
	while(true)
	{
		system("cls");
		order_Print();
		char ch;
		ch = getch();		//#include "conio.h"
		switch(ch)
		{
		case '1':	order_insert();		break;
		case '2':	return;
		}
		system("pause");
	}
}