【C语言】大学课程设计项目——“商场信息管理系统”

“商场信息管理系统”


前言

本文为大一小白期末课程设计作业,如果有同样的课设的小伙伴希望能给你有所帮助,如果产生了一点帮助期望你能给我一个点赞或关注谢谢。

一、项目描述

商场信息管理系统是一个模拟商场管理(如:万达广场、吾悦广场等)。该系统分为2个模块,管理员模块和游客模块。首先实现注册和登录模块;管理员模块是实现商场店铺的管理,采用树来存储商场店铺信息,通过分类来处理,如服装店、餐饮点,然后服装店又分为童装、女装等;游客模块是实现知道商场内所有店铺的信息,输入熟悉店铺名称看商场内有没有等等

二、功能实现

1. 注册功能的实现,账号和密码存储在内存中;

代码如下:

void saveAccountsToFile(Account* accounts, int count,  char* filename) 
{//账号存入文件函数 
    FILE* file = fopen(filename, "w");
    if (file == NULL) 
	{
        printf("无法打开文件 %s\n", filename);
        return;
    }

    int i;
    for (i = 0; i < count; i++) 
	{
        fprintf(file, "%s %s\n", accounts[i].account, accounts[i].password);
    }

    fclose(file);
}

void loadAccountsFromFile(Account* accounts, int count,  char* filename) 
{//读取文件中的信息 
    FILE* file = fopen(filename, "r");
    if (file == NULL) 
	{
        printf("无法打开文件 %s\n", filename);
        return;
    }
    
    int i;
    for (i = 0; i < count; i++) 
	{
        fscanf(file, "%s %s", accounts[i].account, accounts[i].password);
    }
    
    fclose(file);
}

void inputAccountsFromUser(Account* accounts, int count) 
{//注册用户 
    int i;
    for (i=0; i < count; i++) 
	{
		printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
        printf("<\t请输入账号:\t\t\t<\n" );
        scanf("%s", accounts[i].account);
        
        printf("<\t请输入密码:\t\t\t<\n");
        scanf("%s", accounts[i].password);
        printf("<\t注册成功!\t\t\t<\n\n\n");
    }
}

此处使用的文件为accounts.txt,使用时注意要先创建一个accounts.txt文件。

2.登录模块的实现

代码如下:

int login(Account* accounts, int count) //登录系统 
{	
	
    char inputAccount[20];
    char inputPassword[20];
     
    int i,j,k;
    int loggedIn = 0; // 登录状态标志变量,默认为登录失败 
    for (i = 0; i < count; i++) 
	{
		printf("<\t请输入账号:\t\t\t<\n");
        scanf("%s", inputAccount);
    	printf("<\t请输入密码:\t\t\t<\n");
    	scanf("%s", inputPassword);
        for(j=0;j<100;j++) 	
		{
			if(strcmp(inputAccount, accounts[j].account) == 0 && strcmp(inputPassword, accounts[j].password) == 0)
			{
				loggedIn = 1; // 将登录状态标志变量设置为登录成功
				
            	printf("<\t密码正确!登陆成功!\t\t<\n");
	            printf("<\t请输入你的选项:\t\t<\n");
	            printf("<\t3.管理者模式:\t\t\t<\n");
				printf("<\t4.游客模式:\t\t\t<\n:"); 
				scanf("%d",&j);
				if(j==3)
				{
			    TreeNode* root = NULL;
		     
	    		// 添加商品信息
				Product product1 = {"苹果", 6.5, "水果"};
	    		insertProduct(&root, &product1);
	
	    		Product product2 = {"香蕉", 3.0, "水果"};
	    		insertProduct(&root, &product2);
	
	    		Product product3 = {"橙子", 4.0, "水果"};
	    		insertProduct(&root, &product3);
	
	    		Product product4 = {"笔记本电脑", 5000.0, "电子产品"};
	    		insertProduct(&root, &product4);
	
	    		Product product5 = {"手机", 3000.0, "电子产品"};
	    		insertProduct(&root, &product5);
	    		printf("<\t欢迎进入管理者模式!\t\t<\n");
	    		printf("<\t现有商品有:\t\t\t<\n");
	    		printProducts(root);
				printf("<\t请输入你的功能:\t\t<\n");
				printf("<\t1.添加新商品:\t\t\t<\n");
				printf("<\t2.删除新商品:\t\t\t<\n");
				scanf("%d",&k);
					if(k==1)
	    			{
						Product newProduct;//定义新的节点 
	    				inputProduct(&newProduct);//写入商品信息 
	    				insertProduct(&root, &newProduct);//插入到树中并排序 
	    
	    				// 打印商品列表
	    				printProducts(root);
					}
					if(k==2)
					{
						// 删除商品信息
						char deleteName[50];
   						findProduct2(root);
						printf("<\t请再输入一次\t\t\t<\n") ;
   						scanf("%s", deleteName);
						root = deleteProduct(root, deleteName);
    					printf("<\t删除后的商品列表:\t\t<\n");
						// 打印修改后的商品列表
						printProducts(root);
					}
				}
				else if(j==4) 
				{
					TreeNode* root = NULL;
					guestMode(root); 
				}
				else 
				{
					printf("<\t输入错误!将返回上一菜单!请重试!\t\t\t\n");
					return 0; 
				} 
	        }	
		}
		if (!loggedIn) // 如果没有找到匹配的账号和密码,即为登录失败
        printf("登录失败,请检查您的账号和密码。\n");
		
    }
}

其中使用了许多别的函数,如删除函数,查找函数,打印函数等等,下面会写到。

3.游客模式的实现

代码如下:

// 游客模式
void guestMode(TreeNode* root) {
    // 添加初始商品
    Product product1 = {"苹果", 6.5, "水果",0};
    insertProduct(&root, &product1);

    Product product2 = {"香蕉", 3.0, "水果",0};
    insertProduct(&root, &product2);

    Product product3 = {"橙子", 4.0, "水果",0};
    insertProduct(&root, &product3);

    Product product4 = {"笔记本电脑", 5000.0, "电子产品",0};
    insertProduct(&root, &product4);

    Product product5 = {"手机", 3000.0, "电子产品",0};
    insertProduct(&root, &product5);
    
    while (1) {
        int choice;
        
        printf("\n<\t请选择您的操作:\t\t<\n");
        printf("<\t0.返回登录页面\t\t\t<\n");
        printf("<\t1.查看所有商品\t\t\t<\n");
        printf("<\t2.搜索商品\t\t\t<\n");
        printf("<\t3.评价商品\t\t\t<\n");
        printf("<\t请输入您的选择:\t\t<\n");
        scanf("%d", &choice);
        
        if (choice == 1) 
		{
            printf("<\t\n商品清单:\t\t\t<\n");
            printProducts(root);
        }
		else if (choice == 2) 
		{
            findProduct1(root);
        }
		else if (choice == 0) {
            break;
        }
		else if(choice==3)
		{
            rateProductMenu(root);
        }
		else
		{
            printf("<\t无效的选项!请重新输入。\t\t<\n");
        }
    }
}

4.其中的一些重要函数

代码如下:



void insertProduct(TreeNode** root,  Product* product) //排序树 
{//插入商品并且分类 
    if (*root == NULL) //判空 
	{//如果空 
	//创建一个新的树节点作为根节点,并将商品信息复制到节点的 product 字段中。
        *root = (TreeNode*)malloc(sizeof(TreeNode));
        (*root)->product = *product;
        (*root)->left = NULL;//定义为空 
        (*root)->right = NULL;
    }
	else 
	{//比较商品名称 
        if (product->name< (*root)->product.name) 
		{// 若商品名称小于当前节点的名称,则继续在左子树中插入
            insertProduct(&((*root)->left), product);
        }
		else if (product->name> (*root)->product.name) 
		{//如上 
            insertProduct(&((*root)->right), product);
        }
		else 
		{
            // 商品名称相同,根据商品分类决定插入到左子树或右子树
            if (product->category <(*root)->product.category) 
			{
                insertProduct(&((*root)->left), product);
            } else 
			{
                insertProduct(&((*root)->right), product);
            }
        }
    }
}

void inputProduct(Product* product) //输入商品 
{//管理者管理商品函数与下方循环连用 
    printf("请输入商品名称:");
    scanf("%s", product->name);

    printf("请输入商品价格:");
    scanf("%f", &(product->price));

    printf("请输入商品分类:");
    scanf("%s", product->category);
}

void printProducts(TreeNode* root) 
{ //打印商品 用于给游客看商品 
// 添加商品信息
	
    if (root != NULL) 
	{
        printProducts(root->left);
        printf("商品分类:%s\n", root->product.category); 
        printf("商品名称:%s\n", root->product.name);
        printf("商品价格:%.2f\n", root->product.price);
        printf("商品评分:%d\n", root->product.rating);
        printf("\n");
        printProducts(root->right);
    }
}

TreeNode* findMin(TreeNode* node) {
    if (node->left == NULL) {
        return node;
    } else {
        return findMin(node->left);
    }
}

TreeNode* deleteProduct(TreeNode* root, char* name) {
    if (root == NULL) {
        return root;
    }

    int cmp = strcmp(name, root->product.name);
    if (cmp < 0) {
        root->left = deleteProduct(root->left, name);
    } else if (cmp > 0) {
        root->right = deleteProduct(root->right, name);
    } else {
        if (root->left == NULL && root->right == NULL) {
            // 叶子节点,直接删除
            free(root);
            root = NULL;
        } else if (root->left == NULL) {
            // 只有右子树,用右子树替换当前节点
            TreeNode* temp = root;
            root = root->right;
            free(temp);
        } else if (root->right == NULL) {
            // 只有左子树,用左子树替换当前节点
            TreeNode* temp = root;
            root = root->left;
            free(temp);
        } else {
            // 左右子树都存在,找到右子树中最小的节点替换当前节点
            TreeNode* minNode = findMin(root->right);
            root->product = minNode->product;
            root->right = deleteProduct(root->right, minNode->product.name);
        }
    }

    return root;
}


TreeNode* searchProduct(TreeNode* root, char* name) //二叉搜索树查找函数的第一部分 
{
    if (root == NULL || strcmp(name, root->product.name) == 0) 
	{//如果结点到头了或者找到了 则直接返回当前节点
        return root;
    }

    if (strcmp(name, root->product.name) < 0) 
    //如果给定的商品名称小于当前节点的商品名称,则继续在左子树中递归搜索
	{
        return searchProduct(root->left, name);
    } 
	else 
	{
        return searchProduct(root->right, name);
    }
}

void findProduct1(TreeNode* root) //查找函数的第二部分 //游客版 
{
    char name[50];
    printf("请输入要查找的商品名称:");
    scanf("%s", name);
    TreeNode* result = searchProduct(root, name);//调用第一部分 
    if (result != NULL) 
	{
        printf("找到该商品:\n");
        printf("<\t商品名称:%s\t\t\t<\n", result->product.name);
        printf("<\t商品价格:%.2f\t\t\t<\n", result->product.price);
        printf("<\t商品分类:%s\t\t\t<\n", result->product.category);
        printf("<\t商品评价:%d\t\t\t<\n", result->product.rating);
    } 
	else 
	{
        printf("未找到该商品。\n");
    }
}

void findProduct2(TreeNode* root) //查找函数的第二部分 //管理者版 
{
    char name[50];
    printf("<\t请输入要查找的商品名称:\t<\n");
    scanf("%s", name);
    TreeNode* result = searchProduct(root, name);//调用第一部分 
    if (result != NULL) 
	{
        printf("<\t找到该商品:\t\t\t<\n");
    } 
	else 
	{
        printf("<\t未找到该商品。\t\t\t<\n");
    }
}
void rateProduct(TreeNode* root, const char* name, int rating) 
{
    TreeNode* node = searchProduct(root, name);
    if (node != NULL) 
	{
        node->product.rating = rating;
        printf("<\t成功评价商品。\t\t\t<\n");
    }
	else 
	{
        printf("<\t未找到该商品。\t\t\t<\n");
    }
}

void rateProductMenu(TreeNode* root) //游客评价函数 
{
    char name[50];
    int rating;

    printf("<\t请输入要评价的商品名称:\t\t<\n");
    scanf("%s", name);

    printf("<\t请输入评分(0-5):\t\t\t<\n");
    scanf("%d", &rating);

    rateProduct(root, name, rating);
}
int menu(Account *accounts[])
{	
	int num;
	printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
	printf("<\t欢迎使用商场信息管理系统!\t<\n");
	printf("<\t请输入您的选项:\t\t<\n");
	printf("<\t1.注册新用户:\t\t\t<\n");
	printf("<\t2.用户登录:\t\t\t<\n");
	printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
	scanf("%d",&num);
	switch(num)//switch选择1 2 
	{
		case 1:
			inputAccountsFromUser(accounts, 1);
		return;
		case 2:
			login(accounts, 1);
		break;
		default:
			puts("输入错误,请重试");
			return; 
	} 
}


三、源代码

代码如下:

#include <stdio.h> 
#include <string.h> 

typedef struct 
{//用户数组结构体//登录注册 
    char account[20];
    char password[20];
} Account;

typedef struct 
{//商品树,管理者 
    char name[50];
    float price;
    char category[50]; // 添加商品分类字段
    int rating;
} Product;

typedef struct TreeNode //树结构体 
{
    Product product;
    struct TreeNode* left;
    struct TreeNode* right;
} TreeNode;

void insertProduct(TreeNode** root,  Product* product) //排序树 
{//插入商品并且分类 
    if (*root == NULL) //判空 
	{//如果空 
	//创建一个新的树节点作为根节点,并将商品信息复制到节点的 product 字段中。
        *root = (TreeNode*)malloc(sizeof(TreeNode));
        (*root)->product = *product;
        (*root)->left = NULL;//定义为空 
        (*root)->right = NULL;
    }
	else 
	{//比较商品名称 
        if (product->name< (*root)->product.name) 
		{// 若商品名称小于当前节点的名称,则继续在左子树中插入
            insertProduct(&((*root)->left), product);
        }
		else if (product->name> (*root)->product.name) 
		{//如上 
            insertProduct(&((*root)->right), product);
        }
		else 
		{
            // 商品名称相同,根据商品分类决定插入到左子树或右子树
            if (product->category <(*root)->product.category) 
			{
                insertProduct(&((*root)->left), product);
            } else 
			{
                insertProduct(&((*root)->right), product);
            }
        }
    }
}

void inputProduct(Product* product) //输入商品 
{//管理者管理商品函数与下方循环连用 
    printf("请输入商品名称:");
    scanf("%s", product->name);

    printf("请输入商品价格:");
    scanf("%f", &(product->price));

    printf("请输入商品分类:");
    scanf("%s", product->category);
}

void printProducts(TreeNode* root) 
{ //打印商品 用于给游客看商品 
// 添加商品信息
	
    if (root != NULL) 
	{
        printProducts(root->left);
        printf("商品分类:%s\n", root->product.category); 
        printf("商品名称:%s\n", root->product.name);
        printf("商品价格:%.2f\n", root->product.price);
        printf("商品评分:%d\n", root->product.rating);
        printf("\n");
        printProducts(root->right);
    }
}

TreeNode* findMin(TreeNode* node) {
    if (node->left == NULL) {
        return node;
    } else {
        return findMin(node->left);
    }
}

TreeNode* deleteProduct(TreeNode* root, char* name) {
    if (root == NULL) {
        return root;
    }

    int cmp = strcmp(name, root->product.name);
    if (cmp < 0) {
        root->left = deleteProduct(root->left, name);
    } else if (cmp > 0) {
        root->right = deleteProduct(root->right, name);
    } else {
        if (root->left == NULL && root->right == NULL) {
            // 叶子节点,直接删除
            free(root);
            root = NULL;
        } else if (root->left == NULL) {
            // 只有右子树,用右子树替换当前节点
            TreeNode* temp = root;
            root = root->right;
            free(temp);
        } else if (root->right == NULL) {
            // 只有左子树,用左子树替换当前节点
            TreeNode* temp = root;
            root = root->left;
            free(temp);
        } else {
            // 左右子树都存在,找到右子树中最小的节点替换当前节点
            TreeNode* minNode = findMin(root->right);
            root->product = minNode->product;
            root->right = deleteProduct(root->right, minNode->product.name);
        }
    }

    return root;
}


TreeNode* searchProduct(TreeNode* root, char* name) //二叉搜索树查找函数的第一部分 
{
    if (root == NULL || strcmp(name, root->product.name) == 0) 
	{//如果结点到头了或者找到了 则直接返回当前节点
        return root;
    }

    if (strcmp(name, root->product.name) < 0) 
    //如果给定的商品名称小于当前节点的商品名称,则继续在左子树中递归搜索
	{
        return searchProduct(root->left, name);
    } 
	else 
	{
        return searchProduct(root->right, name);
    }
}

void findProduct1(TreeNode* root) //查找函数的第二部分 //游客版 
{
    char name[50];
    printf("请输入要查找的商品名称:");
    scanf("%s", name);
    TreeNode* result = searchProduct(root, name);//调用第一部分 
    if (result != NULL) 
	{
        printf("找到该商品:\n");
        printf("<\t商品名称:%s\t\t\t<\n", result->product.name);
        printf("<\t商品价格:%.2f\t\t\t<\n", result->product.price);
        printf("<\t商品分类:%s\t\t\t<\n", result->product.category);
        printf("<\t商品评价:%d\t\t\t<\n", result->product.rating);
    } 
	else 
	{
        printf("未找到该商品。\n");
    }
}

void findProduct2(TreeNode* root) //查找函数的第二部分 //管理者版 
{
    char name[50];
    printf("<\t请输入要查找的商品名称:\t<\n");
    scanf("%s", name);
    TreeNode* result = searchProduct(root, name);//调用第一部分 
    if (result != NULL) 
	{
        printf("<\t找到该商品:\t\t\t<\n");
    } 
	else 
	{
        printf("<\t未找到该商品。\t\t\t<\n");
    }
}


// 游客模式
void guestMode(TreeNode* root) {
    // 添加初始商品
    Product product1 = {"苹果", 6.5, "水果",0};
    insertProduct(&root, &product1);

    Product product2 = {"香蕉", 3.0, "水果",0};
    insertProduct(&root, &product2);

    Product product3 = {"橙子", 4.0, "水果",0};
    insertProduct(&root, &product3);

    Product product4 = {"笔记本电脑", 5000.0, "电子产品",0};
    insertProduct(&root, &product4);

    Product product5 = {"手机", 3000.0, "电子产品",0};
    insertProduct(&root, &product5);
    
    while (1) {
        int choice;
        
        printf("\n<\t请选择您的操作:\t\t<\n");
        printf("<\t0.返回登录页面\t\t\t<\n");
        printf("<\t1.查看所有商品\t\t\t<\n");
        printf("<\t2.搜索商品\t\t\t<\n");
        printf("<\t3.评价商品\t\t\t<\n");
        printf("<\t请输入您的选择:\t\t<\n");
        scanf("%d", &choice);
        
        if (choice == 1) 
		{
            printf("<\t\n商品清单:\t\t\t<\n");
            printProducts(root);
        }
		else if (choice == 2) 
		{
            findProduct1(root);
        }
		else if (choice == 0) {
            break;
        }
		else if(choice==3)
		{
            rateProductMenu(root);
        }
		else
		{
            printf("<\t无效的选项!请重新输入。\t\t<\n");
        }
    }
}
void rateProduct(TreeNode* root, const char* name, int rating) 
{
    TreeNode* node = searchProduct(root, name);
    if (node != NULL) 
	{
        node->product.rating = rating;
        printf("<\t成功评价商品。\t\t\t<\n");
    }
	else 
	{
        printf("<\t未找到该商品。\t\t\t<\n");
    }
}

void rateProductMenu(TreeNode* root) //游客评价函数 
{
    char name[50];
    int rating;

    printf("<\t请输入要评价的商品名称:\t\t<\n");
    scanf("%s", name);

    printf("<\t请输入评分(0-5):\t\t\t<\n");
    scanf("%d", &rating);

    rateProduct(root, name, rating);
}


void saveAccountsToFile(Account* accounts, int count,  char* filename) 
{//账号存入文件函数 
    FILE* file = fopen(filename, "w");
    if (file == NULL) 
	{
        printf("无法打开文件 %s\n", filename);
        return;
    }

    int i;
    for (i = 0; i < count; i++) 
	{
        fprintf(file, "%s %s\n", accounts[i].account, accounts[i].password);
    }

    fclose(file);
}

void loadAccountsFromFile(Account* accounts, int count,  char* filename) 
{//读取文件中的信息 
    FILE* file = fopen(filename, "r");
    if (file == NULL) 
	{
        printf("无法打开文件 %s\n", filename);
        return;
    }
    
    int i;
    for (i = 0; i < count; i++) 
	{
        fscanf(file, "%s %s", accounts[i].account, accounts[i].password);
    }
    
    fclose(file);
}

void inputAccountsFromUser(Account* accounts, int count) 
{//注册用户 
    int i;
    for (i=0; i < count; i++) 
	{
		printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
        printf("<\t请输入账号:\t\t\t<\n" );
        scanf("%s", accounts[i].account);
        
        printf("<\t请输入密码:\t\t\t<\n");
        scanf("%s", accounts[i].password);
        printf("<\t注册成功!\t\t\t<\n\n\n");
    }
}

int login(Account* accounts, int count) //登录系统 
{	
	
    char inputAccount[20];
    char inputPassword[20];
     
    int i,j,k;
    int loggedIn = 0; // 登录状态标志变量,默认为登录失败 
    for (i = 0; i < count; i++) 
	{
		printf("<\t请输入账号:\t\t\t<\n");
        scanf("%s", inputAccount);
    	printf("<\t请输入密码:\t\t\t<\n");
    	scanf("%s", inputPassword);
        for(j=0;j<100;j++) 	
		{
			if(strcmp(inputAccount, accounts[j].account) == 0 && strcmp(inputPassword, accounts[j].password) == 0)
			{
				loggedIn = 1; // 将登录状态标志变量设置为登录成功
				
            	printf("<\t密码正确!登陆成功!\t\t<\n");
	            printf("<\t请输入你的选项:\t\t<\n");
	            printf("<\t3.管理者模式:\t\t\t<\n");
				printf("<\t4.游客模式:\t\t\t<\n:"); 
				scanf("%d",&j);
				if(j==3)
				{
			    TreeNode* root = NULL;
		     
	    		// 添加商品信息
				Product product1 = {"苹果", 6.5, "水果"};
	    		insertProduct(&root, &product1);
	
	    		Product product2 = {"香蕉", 3.0, "水果"};
	    		insertProduct(&root, &product2);
	
	    		Product product3 = {"橙子", 4.0, "水果"};
	    		insertProduct(&root, &product3);
	
	    		Product product4 = {"笔记本电脑", 5000.0, "电子产品"};
	    		insertProduct(&root, &product4);
	
	    		Product product5 = {"手机", 3000.0, "电子产品"};
	    		insertProduct(&root, &product5);
	    		printf("<\t欢迎进入管理者模式!\t\t<\n");
	    		printf("<\t现有商品有:\t\t\t<\n");
	    		printProducts(root);
				printf("<\t请输入你的功能:\t\t<\n");
				printf("<\t1.添加新商品:\t\t\t<\n");
				printf("<\t2.删除新商品:\t\t\t<\n");
				scanf("%d",&k);
					if(k==1)
	    			{
						Product newProduct;//定义新的节点 
	    				inputProduct(&newProduct);//写入商品信息 
	    				insertProduct(&root, &newProduct);//插入到树中并排序 
	    
	    				// 打印商品列表
	    				printProducts(root);
					}
					if(k==2)
					{
						// 删除商品信息
						char deleteName[50];
   						findProduct2(root);
						printf("<\t请再输入一次\t\t\t<\n") ;
   						scanf("%s", deleteName);
						root = deleteProduct(root, deleteName);
    					printf("<\t删除后的商品列表:\t\t<\n");
						// 打印修改后的商品列表
						printProducts(root);
					}
				}
				else if(j==4) 
				{
					TreeNode* root = NULL;
					guestMode(root); 
				}
				else 
				{
					printf("<\t输入错误!将返回上一菜单!请重试!\t\t\t\n");
					return 0; 
				} 
	        }	
		}
		if (!loggedIn) // 如果没有找到匹配的账号和密码,即为登录失败
        printf("登录失败,请检查您的账号和密码。\n");
		
    }
}


int menu(Account *accounts[])
{	
	int num;
	printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
	printf("<\t欢迎使用商场信息管理系统!\t<\n");
	printf("<\t请输入您的选项:\t\t<\n");
	printf("<\t1.注册新用户:\t\t\t<\n");
	printf("<\t2.用户登录:\t\t\t<\n");
	printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
	scanf("%d",&num);
	switch(num)//switch选择1 2 
	{
		case 1:
			inputAccountsFromUser(accounts, 1);
		return;
		case 2:
			login(accounts, 1);
		break;
		default:
			puts("输入错误,请重试");
			return; 
	} 
}
int main() {
    Account accounts[100];
	loadAccountsFromFile(accounts, 100, "accounts.txt");
    
    // 输出读取到的账号信息
    int i,a;
    /*for (i = 0; i < 100; i++) 
	{
        printf("账号:%s 密码:%s\n", accounts[i].account, accounts[i].password);
    }*/
    // 将账号信息存入文件
    saveAccountsToFile(accounts, 100, "accounts.txt");
    
    
    // 用户输入账号密码
    for(a=0;a<100;a++) 
	menu(accounts);
	
    return 0;
}

总结

以上就是今天要讲的内容,代码很多不完善的地方,欢迎斧正!

  • 13
    点赞
  • 50
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
针对超市的特点,为了帮助超市解决现在面临的问题,提高小型超市的竞争力,我们将开发以下系统:小商店管理系统(基本功能) 1.进货管理: 根据销售情况及库存情况,自动制定进货计划(亦可手工制定修改),可以避免盲目进货造成商品积压。 按计划单有选择性地进行自动入库登记。 综合查询打印计划进货与入库记录及金额。 2.销售管理: 商品正常销售、促销与限量、限期及禁止销售控制。 综合查询各种销售明细记录、各地收银员收银记录以及交结账情况等。 按多种方式统计生成销售排行榜,灵活察看和打印商品销售日、月、年报表。 3.库存管理: 综合查询库存明细记录。 库存状态自动告警提示。如库存过剩、少货、缺货等。软件为您预警,避免库存商品积压损失和缺货。 库存自动盘点计算。 1、开发背景 4 2、功能描述 4 3、业务流程分析 5 4、数据流程分析 7 4.1、数据流程图 7 4.2、数据字典 9 7.1、数据项的描述...................................................................................................................7 7.1、销售/收银处理数据字典................................................................................................7 7.1、进货管理数据字典...........................................................................................................7 7.1、库存管理数据字典...........................................................................................................7 5、概念模型设计 20 6. 逻辑模型设计和优化 22 7. 物理设计和实施 24 7.1、创建基本表......................................................................................................................25 7.1、创建视图..........................................................................................................................30 7.1、创建存储过程..................................................................................................................32 8、课程设计心得体会 34 参考文献 34
吉林大学软件学院的C语言课程设计是为了帮助学生掌握C语言的基本语法、编程技巧和问题解决能力。在这门课程设计中,学生需要完成一个关于C语言的小项目,以展示他们在课堂上所学到的知识和技能。 这个C语言课程设计的目的是让学生在实践中掌握C语言的应用。学生们需要思考如何通过C语言来解决实际问题,同时也要考虑如何设计一个高效、简洁、易于理解和维护的程序。在完成这个项目的过程中,学生们需要灵活运用C语言的各种数据类型、控制语句、函数等知识,并学会使用调试工具来排查和修复程序中可能出现的错误。 作为一个C语言课程设计项目的难度和复杂度应该与课程的教学进度相匹配,既能够挑战学生,又不能过于超出他们的能力范围。学生们可以选择一个他们感兴趣的主题进行设计,并在设计过程中尽可能地运用到课程中所学的内容。这样不仅能够增强学生的学习兴趣和动力,还能提高他们的主动学习和问题解决能力。 在C语言课程设计项目中,吉林大学软件学院也会提供一定的指导和支持。老师们会给予学生们必要的指导,鼓励他们进行自主思考和探索。学生们可以在老师的指导下,逐步完成项目并进行必要的修改和完善。通过这个过程,学生们不仅能够掌握C语言的程序设计,还能培养他们的团队合作能力和解决问题的能力。 总之,吉林大学软件学院的C语言课程设计旨在帮助学生综合应用所学的知识和技能,提高他们的实践能力和解决问题的能力。通过完成这个项目,学生们将更好地掌握C语言的编程技巧,为以后的学习和工作奠定扎实的基础。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

酱汁猪脚饭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值