在这里插入代码片
```/*//宏定义布尔类型
#define BOOL int
#define TRUE 1
#define FALSE 0
定义一个布尔变量
BOOL flag = FALSE;*//*这种方法虽然直观,但依然是换汤不换药,变量flag在编译器看来依然是int类型。新版本总会改进一些不好的地方,所以在最新的C语言标准(C99)解决了布尔类型的问题。C99提供了_Bool 型,所以布尔类型可以声明为 _Bool flag。_Bool依然仍是整数类型,但与一般整型不同的是,_Bool变量只能赋值为0或1,非0的值都会被存储为1。C99还提供了一个头文件 <stdbool.h> 定义了bool代表_Bool,true代表1,false代表0。只要导入 stdbool.h ,就能非常方便的操作布尔类型了。*/
//         把方法的返回类型设置为Bool有什么好处?
//           这样就可以直接在IF()里面调用方法,把返回的Bool值当成IF执行的条件判断了。#include <stdio.h>
#include <iostream>
#include "assert.h"
#include<string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <conio.h>
#include <windows.h>
#include <ctype.h>
#include<time.h>
//#define true 1;
//#define false 0;
struct consumer* opencon();//用户文件操作
struct card* openconid();//卡号文件操作
void mainMenu();//主菜单
void menu();//首页
void inputinfo();//输入信息
void display(); //打印信息
int seseek(char conid[50]);//普通查找
void search();//链表查找
void sortbyconid();//链表排序
void shanchucon();
void modify();//链表修改
void activate();//用户激活
void interface1();//显示界面选择
void displayone();//显示用户激活信息
void changemoney();//交易扣款
void searchone();//交易扣款查询
void shanchuconone();//删除注册信息;
void interface2();//删除用户注册信息
void search2();//查找注册信息
void interface3();//查找菜单
void displaytwo();
void searchtwo();//交易查询
char encryption(char mw);
char decryption(char mw);
using namespace std;struct userinfo {char username[10];char userpwd[10];struct userinfo* next;
}*userhead, * userp;struct consumer {//结构体用户 char conid[50];char conname[20];char consex[20];char conphonenumber[50];int conage;
//  char money[500];struct consumer* next;
} *head;struct card {//结构体卡号 char conid[20];char conname[30];char condate[20];char conphonenumber[50];float money;int flag;struct card* next;
} *g_head;struct cards {//结构体卡号 char conid[20];char conname[30];char condate[20];char conphonenumber[50];float money;struct cards* next;
} *g_card;//struct consumer *consumer;int count = 1;
FILE* fp;struct userinfo* openuserfile() {FILE* ufile;struct userinfo* userp;userp = (struct userinfo*)malloc(sizeof(struct userinfo));userp->next = NULL;ufile = fopen("formuserinfo.txt", "a+");if (ufile == NULL) {printf("所指定文件不能被打开,请与管理员联系。\n");exit(1);}if (ufile != NULL) {struct userinfo* qt;struct userinfo* qe;qe = (struct userinfo*)malloc(sizeof(struct userinfo));qe->next = NULL;qe = userp;while (!feof(ufile)) {qt = (struct userinfo*)malloc(sizeof(struct userinfo));qt->next = NULL;fscanf(ufile, "%s\t\t%s", &qt->username, &qt->userpwd);qe->next = qt;qe = qe->next;}}fclose(ufile);return userp;
}boolean regist() {system("color 8e");FILE* ufile;boolean rflag = false;char runame[10];char rupwd[10];char tch, rerupswd[10];printf("\n");printf("\n");printf("\n");printf("\t\t");printf("请输入您要注册的用户名:");printf("\t");scanf("%s", runame);printf("\n");printf("\t\t");printf("请输入您的注册密码:");int k = 0;while (k < 10 && ((tch = getch()) != '\r')) {if (tch == 8 && k > 0) {putchar('\b');putchar(' ');putchar('\b');k--;}if (!isdigit(tch) && !isalpha(tch))continue;putchar('*');rupwd[k++] = tch;}rupwd[k] = 0;printf("\n");printf("\t\t请再次输入你的注册密码:");k = 0;while (k < 10 && ((tch = getch()) != '\r')) {if (tch == 8 && k > 0) {putchar('\b');putchar(' ');putchar('\b');k--;}if (!isdigit(tch) && isalpha(tch))continue;putchar('*');rerupswd[k++] = tch;}rerupswd[k] = 0;while (strcmp(rerupswd, rupwd)) {int k = 0;system("cls");printf("你两次输入的密码不一致,请从新输入你的注册密码:");printf("\n");printf("\t\t");printf("请输入您的注册密码:\n");while (k < 10 && ((tch = getch()) != '\r')) {if (tch == 8 && k > 0) {putchar('\b');putchar(' ');putchar('\b');k--;}if (!isdigit(tch) && !isalpha(tch))continue;putchar('*');rupwd[k++] = tch;}rupwd[k] = 0;printf("\n");printf("\t\t");printf("请再次输入您的注册密码:\n");k = 0;while (k < 10 && ((tch = getch()) != '\r')); {if (tch == 8 && k > 0) {putchar('\b');putchar(' ');putchar('\b');k--;}if (!isdigit(tch) && !isalpha(tch))continue;putchar('*');rerupswd[k++] = tch;}rerupswd[k] = 0;}struct userinfo* reguser;reguser = (struct userinfo*)malloc(sizeof(struct userinfo));reguser->next = NULL;strcpy(reguser->username, runame);int len = strlen(rupwd);int i = 0;for (i = 0; i < len; i++) {rupwd[i] = encryption(rupwd[i]);}strcpy(reguser->userpwd, rupwd);struct userinfo* uhead = openuserfile();ufile = fopen("formuserinfo.txt", "a+");if (ufile == NULL) {printf("所指定文件不能被打开,注册失败。\n");exit(1);}else {fprintf(ufile, "%s\t\t%s\n", reguser->username, reguser->userpwd);rflag = true;}fclose(ufile);return rflag;
}boolean login() {boolean uflag = false;char uname[10];char tch, upssword[10];struct userinfo* ue;char* mw;printf("\n");printf("\n");printf("\n");printf("\t\t");printf("请输入您的用户名;");printf("\t");scanf("%s", uname);printf("\n");printf("\t\t");printf("请输入您的登陆密码;");int k = 0;while (k < 10 && ((tch = getch()) != '\r')) {if (tch == 8 && k > 0) {putchar('\b');putchar(' ');putchar('\b');k--;}if (!isdigit(tch) && !isalpha(tch))continue;putchar('*');upssword[k++] = tch;}upssword[k] = 0;struct userinfo* uhead = openuserfile();ue = uhead->next;while (ue != NULL) {char temppsw[10];int len = strlen(ue->userpwd);int i;for (i = 0; i < len; i++) {temppsw[i] = decryption(ue->userpwd[i]);}temppsw[i] = 0;if (strcmp(ue->username, uname) == 0 && strcmp(temppsw, upssword) == 0) {uflag = true;break;}ue = ue->next;}while (!uflag) {system("color 4e");system("cls");printf("\t\t\t");printf("您的用户名与密码输入有误,请从新输入!\n");printf("请输入您的用户名:");printf("\t");scanf("%s", uname);printf("\n");printf("\t\t");printf("请输入你的登录密码;");k = 0;while (k < 10 && ((tch = getch()) != '\r')) {if (tch == 8 && k > 0) {putchar('\b');putchar(' ');putchar('\b');k--;}if (!isdigit(tch) && !isalpha(tch))continue;putchar('*');upssword[k++] = tch;}upssword[k] = 0;ue = uhead->next;while (ue != NULL) {char temppsw[10];int len = strlen(ue->userpwd);int i;for (i = 0; i < len; i++) {temppsw[i] = decryption(ue->userpwd[i]);}temppsw[i] = 0;if (strcmp(ue->username, uname) == 0 && strcmp(temppsw, upssword) == 0) {uflag = true;break;}ue = ue->next;}}return uflag;
}char encryption(char mw) {char mm;int m = (int)mw - 8;if (m < 33) {m = m + 94;}mm = (char)m;return mm;
}char decryption(char mw) {char mingwen;int m;m = (int)mw + 8;if (m > 126) {m = m - 94;}mingwen = (char)m;return mingwen;
}int main(){//主界面 system("color 03");printf("\n\n\n\n\n\n\n\n\t\t\t\t");printf("                    欢迎使用");printf("\n\n");printf("\t\t\t|-------------------------------------------------------------------|\n");printf("\t\t\t|   ******************购 物 卡 管 理 系 统3.0*******************    | \n");printf("\t\t\t|-------------------------------------------------------------------|\n");Sleep(1000);system("cls");menu();mainMenu();return 0;
}void interface1() {//显示菜单 int w;int choice = 1;struct card* g_head;system("color 0C");while (choice) {system("cls");printf("\n\n\n\n");printf("\t\t\t****  -----显示菜单 ----- *****\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      1.显示用户信息       |*\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      2.显示用户激活信息   |*\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      3.返回主菜单         |*\n");printf("\t\t\t*|---------------------------|*\n");printf("\n\n");printf("\t\t\t请输入您的操作(1-3)\n");scanf("%d", &w);switch (w) {case 1:printf("你选择的是1.显示用户信息;\n");display();interface1();break;case 2:printf("你选择的是2.显示用户激活信息\n");displayone();system("cls");break;case 3:printf("你选择的是3.返回主菜单");mainMenu();break;}}
}void interface2() {//删除菜单 int w;int choice = 1;system("color 0C");while (choice==1) {system("cls");printf("\n\n\n\n");printf("\t\t\t****  -----删除菜单 ----- *****\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      1.删除用户           |*\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      2.删除用户注册信息   |*\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      3.返回主菜单         |*\n");printf("\t\t\t*|---------------------------|*\n");printf("\n\n");printf("\t\t\t请输入您的操作(1-3)\n");scanf("%d", &w);switch (w) {case 1:printf("你选择的是1.删除用户信息;\n");shanchucon();break;case 2:printf("你选择的是2.删除用户激活信息\n");shanchuconone();system("cls");break;case 3:printf("你选择的是3.返回主菜单");mainMenu();break;}}
}void interface3() {//查找菜单 int w;int choice = 1;system("color 0C");while (choice) {system("cls");printf("\n\n\n\n");printf("\t\t\t****  -----查找菜单 ----- *****\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      1.查找用户           |*\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      2.查找用户注册信息   |*\n");printf("\t\t\t*|                           |*\n");printf("\t\t\t*|      3.返回主菜单         |*\n");printf("\t\t\t*|---------------------------|*\n");printf("\n\n");printf("\t\t\t请输入您的操作(1-3)\n");scanf("%d", &w);switch (w) {case 1:printf("你选择的是1.查找用户信息;\n");search();system("pause");system("cls");break;case 2:printf("你选择的是2.查找用户激活信息\n");search2();system("pause");system("cls");break;case 3:printf("你选择的是3.返回主菜单");mainMenu();break;}}
}void mainMenu() {//主菜单 int c;g_head=openconid();head=opencon();int isExit = 1;struct card* head = NULL;system("color 0B");while (isExit) {system("cls");printf("\n\n\n\n");printf("\t\t\t**********************购物卡管理系统**************************\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                     1.添加用户                           |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                     2.用户激活                           |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                     3.查找用户                           |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                     4.显示菜单                           |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                     5.删除用户                           |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                     6.交易查询                           |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                     7.修改用户信息                       |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                     8.交易扣款                           |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t*|                                                          |*\n");printf("\t\t\t**************************************************************\n");printf("\n\n");printf("\t\t\t请输入您的操作(0-8):");scanf("%d", &c);switch (c) {case 1:printf("你选则的是1.添加用户\n");inputinfo();break;case 2:printf("你选择的是2.用户激活\n");activate();break;case 3:printf("你选择的是3.查找菜单\n");interface3();//seseek(conid);system("pause");break;case 4:printf("你选择的是4.显示菜单\n");interface1();system("pause");break;case 5:printf("你选择的是5.删除菜单\n");interface2();system("pause");break;case 6:printf("你选择的是6.交易查询;\n");searchtwo(); //displaytwo();system("pause");system("cls");mainMenu();break;case 7:printf("你选择的是7.修改用户信息。\n");modify();//    mainMenu();system("pause");break;case 8:printf("你选择的是8.交易扣款.\n");changemoney();mainMenu();break;}}
}void menu() {//管理员注册 登录界面 system("color 8e");int choice;printf("\n\n\n\n");printf("\t\t\t\t*********************************************************\n");printf("\t\t\t\t***___________________________________________________***\n");printf("\t\t\t\t***|                                                 |***\n");printf("\t\t\t\t***|            主菜单                               |***\n");printf("\t\t\t\t***|                                                 |***\n");printf("\t\t\t\t***|          1.管理员注册。                         |***\n");printf("\t\t\t\t***|                                                 |***\n");printf("\t\t\t\t***|          2.管理员登录。                         |***\n");printf("\t\t\t\t***|_________________________________________________|***\n");printf("\t\t\t\t*********************************************************\n");printf("请输入你需要的操作\n");scanf("%d", &choice);if (choice == 1) {regist();printf("\n");printf("用户注册成功,任意键跳转界面!\n");system("pause");system("cls");menu();}else {if (choice == 2) {login();printf("\n");printf("登录成功,任意键跳转界面\n");system("pause");system("cls");mainMenu();}else {exit(1);}}
}void inputinfo() {//添加用户 int i = 1, j;struct consumer* p;//创建两个指针 fp = fopen("用户信息.dat", "a+");//fp为全局变量 文件指针 while (i == 1) {p = (struct consumer*)malloc(sizeof(struct consumer));//开空间 p->next = NULL;                                        //头节点为空节点,往后移一位节点 printf("请输入第%d个用户的信息\n", count++);printf("请输入用户卡号\n");scanf("%s", &p->conid);printf("请输入用户姓名\n");scanf("%s", &p->conname);printf("请输入用户性别\n");scanf("%s", &p->consex);printf("请输入用户年龄\n");scanf("%d", &p->conage);
//      printf("请输入用户存入金额\n");
//      scanf("%s", &p->money);printf("请输入用户手机号码\n");scanf("%s", &p->conphonenumber);printf("是否继续输入下一个同学信息:  1.继续    0.返回     \n"); \scanf("%d", &i);fprintf(fp, "%s\t%s\t%s\t%d\t\%s\n", p->conid, p->conname, p->consex, p->conage, p->conphonenumber);}j = count;fclose(fp);system("pause");system("cls");mainMenu();
}struct consumer* opencon() {//用户信息文件操作 FILE* fp;head = (struct consumer*)malloc(sizeof(struct consumer));head->next = NULL;fp = fopen("用户信息.dat", "r");if (fp == NULL) {printf("所指定文件不能被打开,请与管理员联系\n");exit(1);}if (fp != NULL) {struct consumer* qe, * qt;qe = (struct consumer*)malloc(sizeof(struct consumer));qe->next = NULL;qe = head;while (!feof(fp)) {qt = (struct consumer*)malloc(sizeof(struct consumer));qe->next = NULL;fscanf(fp, "%s\t%s\t%s\t%d\t\%s\t\n\n\n", qt->conid, qt->conname, qt->consex, &qt->conage,  qt->conphonenumber);qe->next = qt;qe = qe->next;}}fclose(fp);return head;}struct card* openconid() {//用户激活信息文件操作 FILE* fp;g_head = (struct card*)malloc(sizeof(struct card));g_head->next = NULL;fp = fopen("用户注册信息.dat", "r");if (fp == NULL) {printf("所指定文件不能被打开,请与管理员联系\n");exit(1);}if (fp != NULL) {struct card *qe, *qt;qe = (struct card*)malloc(sizeof(struct card));qe->next = NULL;qe = g_head;while (!feof(fp)) {qt = (struct card*)malloc(sizeof(struct card));qt->next = NULL;fscanf(fp, "%s%s%s%f%s\n", qt->conid, qt->conname, qt->condate,&qt->money,qt->conphonenumber);qe->next = qt;qe = qe->next;}}fclose(fp);return g_head;interface3();
}void display() {//打印链表 用户信息 struct consumer* p2;p2 = opencon();p2 = p2->next;while (p2 != NULL) {printf("卡号****姓名****性别****年龄****用户手机号码\n");printf("%s\t%s\t%s\t%d\t%10s\t\n\n\n", p2->conid, p2->conname, p2->consex, p2->conage,  p2->conphonenumber);p2 = p2->next;}system("pause");
}struct consumer *seekconid() {//文件操作用户信息 char conphonenumber[50];struct consumer *q1;if (head == NULL) {q1 = opencon();q1 = q1->next;//q1->next=NULL;}else {q1 = head;}printf("请输入需要查找的用户电话号码:");scanf("%s", conphonenumber);while (q1 != NULL) {if (strcmp(q1->conphonenumber,conphonenumber) == 0) {return q1;}else {q1 = q1->next;}//return q1 ;}
}void search() {//链表查找 用户注册信息 struct consumer* qt;qt = seekconid();//  qt=qt->next; // qt->next=NULL;if (qt != NULL) {printf("卡号****姓名****性别****年龄****用户手机号码\n");printf("%s\t%s\t%s\t%d\t%12s\t\n\n\n", qt->conid, qt->conname, qt->consex, qt->conage,  qt->conphonenumber);}else {printf("没有此用户的信息,请添加!\n");system("pause");system("cls");mainMenu();}
}void modify() {int choice = 1;struct consumer *qt, *qe;FILE *fp;fp = fopen("用户信息.dat", "w+");if (fp == NULL) {printf("所指定文件不能被打开,请与工作人员联系\n");exit(1);}if (fp != NULL) {qe = seekconid();if (qe == NULL) {printf("没有此用户的信息。请添加\n");return;}else {printf("卡号****姓名****性别****年龄****用户手机号码\n");printf("%s\t%s\t%s\t%d\t%14s\t\n\n\n", qe->conid, qe->conname, qe->consex, qe->conage,  qe->conphonenumber);//  printf("是否修改用户信息\n");//   printf("1.确定修改  0.返回上一级\n");//    scanf("%d",&choice);printf("请输入需要修改的内容\n");printf("请输入用户卡号:\n");scanf("%s", qe->conid);printf("请输入用户姓名\n");scanf("%s", qe->conname);printf("请输入用户性别\n");scanf("%s", qe->consex);printf("请输入用户年龄\n");scanf("%d", &qe->conage);
//          printf("请输入用户存入金额\n");
//          scanf("%s", qe->money);printf("请输入用户手机号码\n");scanf("%s", qe->conphonenumber);}}qt = head;qt = qt->next;while (qt != NULL) {fprintf(fp, "%s\t%s\t%s\t%d\t%s\t\n\n\n", qt->conid, qt->conname, qt->consex, qt->conage,  qt->conphonenumber);qt = qt->next;}fclose(fp);printf("修改成功\n");printf("系统将会在三秒后跳转至主菜单");Sleep(3000);system("cls");mainMenu();
}/*struct consumer *deletecon(){//删除文件操作struct consumer *pdest;struct consumer *pbefore;char conid[50];assert(pdest!=NULL);while(pdest->next!=NULL && pdest->conid!=conid){pbefore=pdest;pdest=pdest->next;}if(pdest->conid==conid){}if(pdest==head){head=pdest->next;}else{pbefore->next=pdest->next;}free(pdest);printf("该用户已被删除!");}*/void shanchucon() {struct consumer* qt, *qe, *qq;FILE* fp;qe=opencon(); char conphonenumber[50];printf("请输入删除用户的电话号码:\n");scanf("%s", conphonenumber);记录前一个节点进行qe = head;qt = head; //遍历链表查找,查找到后进行信息显示bool isShowhead = false; //对表头进行展示一次bool isFindcon = false; //记录是否有找到该用户的用户信息while (qt != NULL) {if (strcmp(conphonenumber, qt->conphonenumber) == 0) {if (!isShowhead) {printf("卡号****姓名****性别****年龄****用户手机号码\n");isShowhead = true;}printf("%s\t%s\t%s\t%d\t%14s\t\n\n\n", qt->conid, qt->conname, qt->consex, qt->conage,  qt->conphonenumber);isFindcon = true;printf("************************************\n");if (qt->next == NULL) {//删除节点为尾节点 qe->next = NULL;}else {//删除节点为中间节点 qe->next = qt->next;}printf("删除成功\n");qq = head;qq = qq->next;fp = fopen("用户信息.dat", "w+");while (qq != NULL) {fprintf(fp, "%s\t%s\t%s\t%d\t%s\t\n\n\n", qq->conid, qq->conname, qq->consex, qq->conage, qq->conphonenumber);qq = qq->next;}fclose(fp);}qe = qt;qt = qt->next;}if (!isFindcon) {printf("卡号有误,系统中暂无该用户信息,无法进行删除\n");}system("pause");system("cls");interface2();
}void activate() {//用户激活 int i = 1;int j;struct card *p;struct consumer *qt;fp = fopen("用户注册信息.dat", "a+");qt = seekconid();if(qt==NULL){printf("系统中没有该用户的信息,请先注册或激活\n"); system("pause");mainMenu();}else{while (i == 1) {printf("卡号****姓名****性别****年龄****用户手机号码\n");printf("%s\t%s\t%s\t%d\t%10s\t\n\n\n", qt->conid, qt->conname, qt->consex, qt->conage, qt->conphonenumber);p = (struct card*)malloc(sizeof(struct card));
//      p->next = NULL;printf("请输入该用户的激活信息\n", count++);printf("请输入用户卡号\n");scanf("%s", p->conid);printf("请输入用户姓名\n");scanf("%s", p->conname);printf("请输入发卡日期\n");scanf("%s", p->condate);printf("请输入用户当前余额\n");scanf("%f", &p->money);printf("请输入用户手机号码\n");scanf("%s", p->conphonenumber);printf("此购物卡已激活成功");printf("是否继续激活下一位用户卡号:   1.继续     0.返回    \n");scanf("%d", &i);fprintf(fp, "%s\t%s\t%s\t%.2f\t%s\t\n\n", p->conid, p->conname, p->condate, p->money, p->conphonenumber);}}j = count;fclose(fp);system("pause");system("cls");mainMenu();
}struct card* opencard() {FILE* fp;g_head = (struct card*)malloc(sizeof(struct card));g_head->next = NULL;fp = fopen("用户注册信息.dat", "r");if (fp == NULL) {printf("所指定文件不能被打开,请与管理员联系\n");exit(1);}if (fp != NULL) {struct card* qe, * qt;qe = (struct card*)malloc(sizeof(struct card));qe->next = NULL;qe = g_head;while (!feof(fp)) {qt = (struct card*)malloc(sizeof(struct card));qe->next = NULL;fscanf(fp, "%s\t%s\t%s\t%.2f\t%s\t\n\n", qt->conid, qt->conname, qt->condate, &qt->money, qt->conphonenumber);qe->next = qt;qe = qe->next;}}fclose(fp);return g_head;
}void displayone() {FILE* fp;struct card *p2;p2 = openconid();p2 = p2->next;while (p2 != NULL) {printf("卡号****持卡人姓名****激活时间*******余额*******持卡人手机号码\n");printf("%s\t%s\t%12s\t     %.2f\t%s\t\n\n", p2->conid, p2->conname, p2->condate, p2->money, p2->conphonenumber);p2 = p2->next;}system("pause");
}
void searchone() {//链表查找 struct consumer* qt;qt = seekconid();//   qt=qt->next; // qt->next=NULL;if (qt != NULL) {printf("卡号****姓名****性别****年龄****用户手机号码\n");printf("%s\t%s\t%s\t%d\t%s%20s\t\n\n\n", qt->conid, qt->conname, qt->consex, qt->conage, qt->conphonenumber);}else {printf("没有此用户的信息,请添加!\n");system("pause");system("cls");mainMenu();}
}void shanchuconone() {struct card* qt, * qe, * qq;FILE* fp;
//  fp = fopen("用户注册信息.dat", "w+");qe=openconid();
//  system("cls");char conphonenumber[50];printf("请输入删除用户的电话号码:\n");scanf("%s", conphonenumber);记录前一个节点进行qe = g_head;qt = g_head;//遍历链表查找,查找到后进行信息显示bool isShowhead = false;//对表头进行展示一次bool isFindcon = false;//记录是否有找到该用户的学生信息while (qt != NULL) {if (strcmp(conphonenumber, qt->conphonenumber) == 0) {if (!isShowhead) {printf("卡号****持卡人姓名****激活时间****余额****持卡人手机号码\n");isShowhead = true;}printf("%s\t%s\t%14s\t%.2f\t%14s\t\n\n\n", qt->conid, qt->conname, qt->condate, qt->money, qt->conphonenumber);isFindcon = true;printf("************************************\n");if (qt->next == NULL) {//删除节点为尾节点 qe->next = NULL;}else {//删除节点为中间节点 qe->next = qt->next;}printf("删除成功\n");qq = g_head;qq = qq->next;fp = fopen("用户注册信息.dat", "w+");while (qq != NULL) {fprintf(fp, "%s\t%s\t%14s\t%14s\t\n\n\n", qq->conid, qq->conname, qq->condate,&qq->money, qq->conphonenumber);qq = qq->next;}fclose(fp);}qe = qt;qt = qt->next;}if (!isFindcon) {printf("卡号有误,系统中暂无该用户信息,无法进行删除\n");}system("pause");system("cls");interface2();
}struct card* seekcon() {//文件操作 用户注册信息 char conphonenumber[20];struct card *q1;if (g_head == NULL) {g_head = openconid();q1=g_head;q1 = q1->next;//q1->next=NULL;}else {q1 = g_head;}printf("请输入需要查找的用户电话号码:");scanf("%s", &conphonenumber);while (q1 != NULL) {if (strcmp(q1->conphonenumber, conphonenumber) == 0) {return q1;}q1 = q1->next;}}void search2() {//链表查找 激活信息 struct card* qt;qt = seekcon();//  qt=qt->next; // qt->next=NULL;if (qt != NULL) {printf("卡号****持卡人姓名****激活时间****余额*********持卡人手机号码\n");printf("%s\t%s\t%14s\t  %.2f\t%12s\t\n\n\n", qt->conid, qt->conname, qt->condate, qt->money, qt->conphonenumber);}else {printf("没有此用户的信息,请添加!\n");system("pause");system("cls");interface3();}
}void changemoney(){float s=0;int choice =1;struct card *qe, *qt;FILE *fp;FILE* fp1;fp=fopen("用户注册信息.dat","w+");//用户注册记录 fp1=fopen("交易记录.dat","a+"); if(fp==NULL){printf("所指定文件不能被打开,请与管理员联系\n");exit(1);  }if(fp!=NULL){qe=seekcon();if(qe==NULL){printf("没有此用户的信息,请先注册或添加\n");return ; }else{printf("\n\n");printf("\t\t\t********************账户消费*******************");printf("\n\n");printf("\t\t\t请输入您的消费金额:");scanf("%f",&s);if(s>qe->money){printf("你的余额不足,请充值!\n");}else{qe->money=qe->money-s;}printf("\n\n\t\t\t您的余额为:%.2f\n",qe->money);printf("\n\n\n\n\n\t\t\t显示完毕,按任意键返回子菜单.....");  qt=g_head;qt=qt->next;while(qt!=NULL){fprintf(fp, "%s\t%s\t%s\t%.2f\t%s\n", qt->conid, qt->conname, qt->condate, qt->money, qt->conphonenumber);fprintf(fp1, "%s\t%s\t%s\t%.2f\t%s\n", qt->conid, qt->conname, qt->condate, qt->money, qt->conphonenumber);qt=qt->next;}}} fclose(fp);fclose(fp1);system("pause");
}struct cards* openone(){//文件操作 交易查询 FILE* fp;
//  struct cards *g_card1;g_card=(struct cards*)malloc(sizeof(struct cards));g_card->next=NULL;fp=fopen("交易记录.dat","r");if(fp==NULL){printf("所指定文件不能被打开,请与管理员联系\n");exit(1); }if(fp!=NULL){struct cards* qe, *qt;qe=(struct cards*)malloc(sizeof(struct cards));qe->next=NULL;qe=g_card; while(!feof(fp)){qt=(struct cards*)malloc(sizeof(struct cards));qt->next=NULL;fscanf(fp, "%s%s%s%f%s\n", qt->conid, qt->conname, qt->condate, &qt->money, qt->conphonenumber);qe->next=qt;qe=qe->next;} }fclose(fp);return g_card;
}/*void searchtwo(){struct cards *qt;char conphonenumber[50];printf("请输入你需要查找的用户手机号码\n");scanf("%s",conphonenumber);if(g_card==NULL){qt=openone();//qt=g_card;qt=qt->next;g_card =g_card->next;}else{qt=g_card;qt=qt->next;}
//  printf("one %p",qt); while(qt!=NULL){if(strcmp(qt->conphonenumber,conphonenumber)==0){printf("卡号****持卡人姓名****激活时间****余额****持卡人手机号码\n");printf("%s\t%s\t%12s\t %.2f\t%14s\n", qt->conid, qt->conname, qt->condate, qt->money, qt->conphonenumber);        }else{printf("没有此用户的消费信息!\n");} qt=qt->next;}system("pause");mainMenu();
}
*/
void displaytwo() {FILE* fp;struct cards *p2;p2 = openone();p2 = p2->next;while (p2 != NULL) {printf("卡号****持卡人姓名****激活时间****余额****持卡人手机号码\n");printf("%s\t%s\t%s\t%.2f\t%s\t\n\n", p2->conid, p2->conname, p2->condate, p2->money, p2->conphonenumber);p2 = p2->next;}system("pause");
}void searchtwo(){struct cards *qt;int flag=0;char conphonenumber[50];printf("请输入你需要查找的用户手机号码:\n");scanf("%s",conphonenumber);if(g_card==NULL){qt=openone();qt=qt->next;g_card=g_card->next;}else{qt=g_card;qt=qt->next;}while(qt!=NULL){if(strcmp(qt->conphonenumber,conphonenumber)==0){printf("卡号****持卡人姓名****激活时间****余额****持卡人手机号码\n");printf("%s\t%s\t%12s\t %.2f\t%14s\n", qt->conid, qt->conname, qt->condate, qt->money, qt->conphonenumber);flag=1;}qt=qt->next;         }if(flag==0){printf("没有此用户的消费信息!\n"); }system("pause");mainMenu();
} 

简单的购物卡管理系统 可开源相关推荐

  1. 制造业BOM 工厂BOM管理系统 简单实用BOM管理系统,树形结构,目视化BOM管理系统,集成ERP、SAP的BOM管理系统,快速上线BOM管理系统

    这是之前开发的BOM业务,实现如下功能: bom资料.基础物料的导入导出.支持导入到sap: web目视化界面,可以对内容修改: 有校对基础资料功能.日志操作明细: 本考虑使用java开发,客户需求统 ...

  2. php知识管理系统,PHP开源内容管理系统YzmCMS

    YzmCMS是一款轻量级开源内容管理系统,它采用OOP面向对象方式开发的框架.基于LAMP架构,并采用YZMPHP轻量级开源MVC框架开发的一款高效开源的内容管理系统,可运行在Linux.Window ...

  3. 基于Java的简单零食商城管理系统

    标题# 基于Java的简单零食商城管理系统 专业团队开发,接受定制 联系VX:Alfalfa-cx 专属源码网站欢迎浏览:http://www.eqicode.com/Code/Index.html ...

  4. python小项目实例流程-Python小项目:快速开发出一个简单的学生管理系统

    原标题:Python小项目:快速开发出一个简单的学生管理系统 本文根据实际项目中的一部分api 设计抽象出来,实例化成一个简单小例子,暂且叫作「学生管理系统」. 这个系统主要完成下面增删改查的功能: ...

  5. python小项目案例-Python小项目:快速开发出一个简单的学生管理系统

    本文根据实际项目中的一部分api 设计抽象出来,实例化成一个简单小例子,暂且叫作「学生管理系统」. 这个系统主要完成下面增删改查的功能: 包括: 学校信息的管理 教师信息的管理 学生信息的管理 根据A ...

  6. 最简单的彩灯管理系统

    最简单的彩灯管理系统 一.用Proteus软件来绘制电路图 二.用Keil软件来写程序 三.将Keil写的代码,放进Proteus的仿真图中 实验题目: 将P2端口连接LED发光二极管,连接的高4个与 ...

  7. C语言学生成绩简单,C语言实现简单学生成绩管理系统.pdf

    C语言实现简单学生成绩管理系统 这篇文章主要为大家详细介绍了C语言实现简单学生成绩管理系统,具有 定的参考价值,感兴趣的小伙伴们可以 参考 下 本文实例为大家分享了C语言实现学生成绩管理系统的具体代码 ...

  8. php手游管理系统,搭建简单的游戏管理系统

    这次给大家带来搭建简单的游戏管理系统,搭建简单游戏管理系统的注意事项有哪些,下面就是实战案例,一起来看一下. 一. 分析&布局设计 当前我们项目的界面是这样的: 简单来说,看不出一点管理系统的 ...

  9. 双链表嵌套的简单学生信息管理系统

    参考:实现双链表嵌套的简单学生信息管理 作者:三速何时sub20 发布时间: 2020-07-20 10:44:40 网址:https://blog.csdn.net/weixin_44234294/ ...

最新文章

  1. html 根据坐标画多边形,28种css3绘制多边形代码分享
  2. linux ssh Unused,ssh免密码登录 - leopardlinux的个人空间 - OSCHINA - 中文开源技术交流社区...
  3. Java8Stream
  4. git和码云的使用以及搭建git服务器
  5. hbase数据库介绍,HBASE的特点,表结构逻辑视图,Row Key,列族,时间戳,Cell
  6. 0.《沉浸式线性代数》:前言
  7. 【转载】oracle normal、sys、system、sysdba、sysoperdba的区别
  8. 【Python-3.5】绘制随机漫步图
  9. vmware虚拟机网络模式
  10. Vijos P1097 合并果子【哈夫曼树+优先队列】
  11. redis安装配置 mysql_学习环境安装 mysql 与 redis
  12. vs2010+open244的永久性配置
  13. java中NULL与 的区别
  14. mysql 插入数据 自增长_mysql插入数据后返回自增ID的方法
  15. 三维随机介质模型matlab,基于随机介质理论的复合材料孔隙二维形貌几何仿真
  16. android平板管理工具,安卓平板如何提升使用效率,这17款软件你应该知道
  17. 信息安全系统所需要遵循的基本原则有哪些?
  18. 计算机大赛鼓励语录,致2019年的自己 鼓励自己的经典语句
  19. mysql slap_组合方法和SLAP
  20. 2022半导体芯片人才市场趋势报告

热门文章

  1. jquery抓娃娃机代码
  2. # **PS CC2019 安装破解教程**
  3. 太阳光是平行光吗_为什么说太阳光线是平行的
  4. 一文讲解灰光模块和彩光模块
  5. 【MindSpore】【数据集】数据集内数据获取失败导致迭代器退出
  6. 未来已来!阿里小蜜AI技术揭秘
  7. awtk + scons资源/问题/调试
  8. docker 命令补全
  9. 基于linux网络流量监控与分析软件的设计与实现shell,Shell图形化监控网络流量
  10. java 输出乘法口诀第一列_java输出乘法口诀表