C语言大作业:车辆管理系统

声明
此代码使用VS2019编译器进行编译
使用 vc 和 dev-c 的有可能会出现编译警告,需要自己去网上查找相关的编译环境的问题
其次使用vs编译器也可能会报 C4996 错误,请自行搜索 C4996 错误
最后也是最容易忽略的错误,C/C++编译器常使用ASCII码
CSDN上直接复制的代码是UTF-8格式的需要自己手动调(自行搜索)

要注意文件读写问题需要跟编译器环境有关系当时编写没考虑其他编译环境
需要自己去搜读取和写入的函数可以自己进行修改

本代码已经尝试很多次已确定代码格式无误.报错问题绝大部分与编译器的调制有关


此外
由于这是作者大一时候编写的,不一定有时间及时回答真想问加Q:1403145273并写明
一起学习

流程图




代码

声明

由于很多人说我的程序执行失败,我在此解释一下
我的编译环境是VS2019 使用dev和VC的在scanf_s会报错,因为这个函数是VS才有的好像

总之不能使用的时候建议百度

其次 由于不同的编译环境对程序的要求不同,有些需要调整编译器的警告等级才能使用

在执行程序前,需要在当前cpp文件夹内自己手动建立car.txt文本才能运行成功
请看仔细点
初始化信息是在car.txt文件内的,我没有写在程序内所有在运行时会显示没有内容
要写初始化信息自己先运行程序中输入新的信息录入才会更新初始化内容

文件尾的问题也是CSDN在复制长代码的时候会出现的问题,需要分开复制
IntelliSense:此声明没有存储类型或类型说明符 同理

大部分都是出现在IO流的问题,请自行根据自己的编译器进行调整

​#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct car;
typedef struct list_car;
typedef struct list_car_sequence;
list_car* rear=NULL;
/* 数据模型 */
struct car {char type_of_name[10];//车型char manufacturer[10];//厂商char model_class[10];//车型级别char seating_number[10];//座位数char output_volume[10];//排量char transmission_case[10];//变速箱char color[10];//颜色char prize[10];//价格
};
/* 链表 */
struct list_car {car* imformation;list_car* next;
};
/* 按顺序排列链表 */
struct list_car_sequence {char name[10];char imformation[10];list_car_sequence* next;
};/* [结构体] 从 [文本] 获得信息 */
list_car* read_list_car() {FILE* fp;list_car* create, * head = NULL;int num = 0;if ((fp = fopen("car.txt", "r")) == NULL) {printf("打开文件失败");exit(0);}create = rear = (list_car*)malloc(sizeof(list_car));create->imformation = (car*)malloc(sizeof(car));while ((fscanf(fp, "%s", create->imformation->type_of_name)) != EOF) {fscanf(fp, "%s""%s""%s""%s""%s""%s""%s", create->imformation->manufacturer, create->imformation->model_class, create->imformation->seating_number, create->imformation->output_volume, create->imformation->transmission_case, create->imformation->color, create->imformation->prize);num++;if (num == 1)head = rear;elserear->next = create;rear = create;create = (list_car*)malloc(sizeof(list_car));create->imformation = (car*)malloc(sizeof(car));}rear->next = NULL;free(create->imformation);free(create);fclose(fp);printf("录入成功");return head;
}/* [文本] 从 [结构体] 获得信息 */
void write_list_car(list_car*head) {FILE* fp;if ((fp = fopen("car.txt", "w")) == NULL) {printf("打开文件失败");}list_car* p = head;for(;p!=NULL;p=p->next)fprintf(fp,"%s ""%s ""%s ""%s ""%s ""%s ""%s ""%s", p->imformation->type_of_name, p->imformation->manufacturer, p->imformation->model_class, p->imformation->seating_number, p->imformation->output_volume, p->imformation->transmission_case, p->imformation->color, p->imformation->prize);printf("写入文件成功!\n");fclose(fp);
}/******************************************************//*     修改  *//*************************************************************//* 录入车辆信息进 [结构体内]  */
void list_car_write(list_car*rear) {list_car* p = (list_car*)malloc(sizeof(list_car));p->next = NULL;//容易漏p->imformation = (car*)malloc(sizeof(car));printf("请输入\n");scanf_s("%s""%s""%s""%s""%s""%s""%s""%s", p->imformation->type_of_name, sizeof(p->imformation->type_of_name), p->imformation->manufacturer, sizeof(p->imformation->manufacturer), p->imformation->model_class, sizeof(p->imformation->model_class), p->imformation->seating_number, sizeof(p->imformation->seating_number), p->imformation->output_volume, sizeof(p->imformation->output_volume), p->imformation->transmission_case, sizeof(p->imformation->transmission_case), p->imformation->color, sizeof(p->imformation->color), p->imformation->prize, sizeof(p->imformation->prize));getchar();if(rear!=NULL)rear->next = p;rear = p;
}/* 修改 [结构体内] 车辆具体信息 */
void list_car_alter(list_car* head) {if (head == NULL) {printf("头指针为空!\n");return;}list_car* p = head;char name[20];printf("请输入型号:\n");scanf_s("%s", name, sizeof(name));getchar();for (;p != NULL;p = p->next)if (strcmp(name, p->imformation->type_of_name) == 0)break;if (p == NULL) {printf("没有找到该类型!\n");return;}printf("请输入修改类型的序号:\n");char imformation;imformation = getchar();printf("请输入修改后内容\n");switch (imformation){case '1':scanf_s("%s", p->imformation->type_of_name, sizeof(p->imformation->type_of_name));break;case '2':scanf_s("%s", p->imformation->manufacturer, sizeof(p->imformation->manufacturer));break;case '3':scanf_s("%s", p->imformation->model_class, sizeof(p->imformation->model_class));break;case '4':scanf_s("%s", p->imformation->seating_number, sizeof(p->imformation->seating_number));break;case '5':scanf_s("%s", p->imformation->output_volume, sizeof(p->imformation->output_volume));break;case '6':scanf_s("%s", p->imformation->transmission_case, sizeof(p->imformation->transmission_case));break;case '7':scanf_s("%s", p->imformation->color, sizeof(p->imformation->color));break;case '8':scanf_s("%s", p->imformation->prize, sizeof(p->imformation->prize));break;}getchar();printf("修改成功!\n");}/* 删除 [结构体内] 车辆信息 */
void list_car_delete(list_car* head) {if (head == NULL) {printf("头指针为空!\n");return;}printf("进入修改\n");list_car* p = head,*t=head;char name[20];printf("请输入\n");scanf_s("%s", name, sizeof(name));getchar();for (;p != NULL;p = p->next)if (strcmp(name, p->imformation->type_of_name) == 0) {printf("已找到\n");break;}elset = p;if (p == NULL) {printf("没有找到该类型!\n");return;}printf("请输入删掉的内容\n");char information;loop:scanf_s("%c", &information, sizeof(information));getchar();switch (information) {//结构体里的字符型数组是不能被赋值的,我也不知道为什么.好像是被当成了常量case '0':t->next = p->next;printf("删除成功!\n");break;case '1':strcpy(p->imformation->manufacturer, "无信息");break;case '2':strcpy(p->imformation->model_class, "无信息");break;case '3':strcpy(p->imformation->seating_number, "无信息");break;case '4':strcpy(p->imformation->output_volume, "无信息");break;case '5':strcpy(p->imformation->transmission_case, "无信息");break;case '6':strcpy(p->imformation->color, "无信息");break;case '7':strcpy(p->imformation->prize, "无信息");break;default:printf("无法识别该序号,请重新输入序号");goto loop;}
}/******************************************************//*     修改  *//*************************************************************//******************************************************//*     输出  *//*************************************************************//* 查询 [结构体内] 车辆具体信息 */
void search(list_car* head) {if (head == NULL) {printf("头指针为空!\n");return;}void search_prize(list_car * head);void search_other(list_car * head);char find[10] = { 0 };//字符初始化printf("请输入你想查找的范围:例如 价格 、 厂商 、 车型级别 ,退出则输入 退出\n");scanf_s("%s", find, sizeof(find));while ((strcmp(find,"退出")!=0)) {getchar();if (strcmp(find, "价格") == 0)search_prize(head);else if (strcmp(find, "厂商") == 0 || strcmp(find, "车型级别") == 0)search_other(head);elseprintf("搜索没有此项,请重新输入\n");printf("请输入你想查找的范围:例如 价格 、 厂商 、 车型级别 ,退出则输入 退出\n");scanf_s("%s", find, sizeof(find));}}
void search_prize(list_car* head) {list_car* p = head;list_car_sequence* sequence_head = NULL;list_car_sequence* list_prize_sequence(list_car_sequence * sequence_head, list_car * p);float prize_down, prize_high;printf("请依次输入最低价格和最高价格\n");scanf_s("%f%f", &prize_down, &prize_high);for (;p != NULL;p = p->next)if (atof(p->imformation->prize) >= prize_down && atof(p->imformation->prize) <= prize_high)sequence_head = list_prize_sequence(sequence_head, p);if (sequence_head == NULL) {printf("该价格范围内无车辆型号:\n");return;}for (;sequence_head != NULL;sequence_head = sequence_head->next,printf("\n"))printf("%s\t%s\n", sequence_head->name,sequence_head->imformation);}
void search_other(list_car* head) {list_car_sequence* list_dissequence(list_car_sequence * dissequence, list_car * p);list_car* p = head;list_car_sequence* dissequence_head=NULL;void list_prize_sequence(list_car_sequence * sequence_head, list_car*p);printf("请输入你想找的内容:\n");char name[20] = { 0 };scanf_s("%s", name, sizeof(name));getchar();for (;p != NULL;p = p->next)if (strcmp(name, p->imformation->manufacturer) == 0 || strcmp(name, p->imformation->model_class) == 0 ) {dissequence_head = list_dissequence(dissequence_head, p);}if (dissequence_head == NULL) {printf("没有找到相关内容!\n");return;}for (;dissequence_head != NULL;dissequence_head = dissequence_head->next)printf("%s\n", dissequence_head->name);}list_car_sequence* list_prize_sequence(list_car_sequence* sequence_head, list_car* p) {if (sequence_head == NULL) {sequence_head = (list_car_sequence*)malloc(sizeof(list_car_sequence));strcpy(sequence_head->imformation, p->imformation->prize);strcpy(sequence_head->name, p->imformation->type_of_name);sequence_head->next = NULL;return sequence_head;}else {list_car_sequence* t = sequence_head, * next = NULL, * x = sequence_head;for (;sequence_head != NULL;sequence_head = sequence_head->next) {if (atof(sequence_head->imformation) >= atof(p->imformation->prize)) {if (t == sequence_head) {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));next->next = sequence_head;strcpy(next->imformation, p->imformation->prize);strcpy(next->name, p->imformation->type_of_name);return next;}else {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));t->next = next;next->next = sequence_head;strcpy(next->imformation, p->imformation->prize);strcpy(next->name, p->imformation->type_of_name);return x;}}elset = sequence_head;}if (sequence_head == NULL) {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));strcpy(next->imformation, p->imformation->prize);strcpy(next->name, p->imformation->type_of_name);t->next = next;next->next = NULL;return x;}}
}
list_car_sequence* list_seating_sequence(list_car_sequence* sequence_head, list_car* p) {if (sequence_head == NULL) {sequence_head = (list_car_sequence*)malloc(sizeof(list_car_sequence));strcpy(sequence_head->imformation, p->imformation->seating_number);strcpy(sequence_head->name, p->imformation->type_of_name);sequence_head->next = NULL;return sequence_head;}else {list_car_sequence* t = sequence_head, * next = NULL, * x = sequence_head;for (;sequence_head != NULL;sequence_head = sequence_head->next) {if (atof(sequence_head->imformation) >= atof(p->imformation->seating_number)) {if (t == sequence_head) {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));next->next = sequence_head;strcpy(next->imformation, p->imformation->seating_number);strcpy(next->name, p->imformation->type_of_name);return next;}else {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));t->next = next;next->next = sequence_head;strcpy(next->imformation, p->imformation->seating_number);strcpy(next->name, p->imformation->type_of_name);return x;}}elset = sequence_head;}if (sequence_head == NULL) {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));strcpy(next->imformation, p->imformation->seating_number);strcpy(next->name, p->imformation->type_of_name);t->next = next;next->next = NULL;return x;}}
}
list_car_sequence* list_output_sequence(list_car_sequence* sequence_head, list_car* p) {if (sequence_head == NULL) {sequence_head = (list_car_sequence*)malloc(sizeof(list_car_sequence));strcpy(sequence_head->imformation, p->imformation->output_volume);strcpy(sequence_head->name, p->imformation->type_of_name);sequence_head->next = NULL;return sequence_head;}else {list_car_sequence* t = sequence_head, * next = NULL, * x = sequence_head;for (;sequence_head != NULL;sequence_head = sequence_head->next) {if (atof(sequence_head->imformation) >= atof(p->imformation->output_volume)) {if (t == sequence_head) {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));next->next = sequence_head;strcpy(next->imformation, p->imformation->output_volume);strcpy(next->name, p->imformation->type_of_name);return next;}else {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));t->next = next;next->next = sequence_head;strcpy(next->imformation, p->imformation->output_volume);strcpy(next->name, p->imformation->type_of_name);return x;}}elset = sequence_head;}if (sequence_head == NULL) {next = (list_car_sequence*)malloc(sizeof(list_car_sequence));strcpy(next->imformation, p->imformation->output_volume);strcpy(next->name, p->imformation->type_of_name);t->next = next;next->next = NULL;return x;}}
}
list_car_sequence* list_dissequence(list_car_sequence* dissequence, list_car* p) {if (dissequence == NULL) {dissequence = (list_car_sequence*)malloc(sizeof(list_car_sequence));strcpy(dissequence->name, p->imformation->type_of_name);strcpy(dissequence->imformation,"/0");dissequence->next = NULL;return dissequence;}else {list_car_sequence* creat = (list_car_sequence*)malloc(sizeof(list_car_sequence));strcpy(creat->name, p->imformation->type_of_name);strcpy(creat->imformation, "/0");creat->next = dissequence;return creat;}
}/* 浏览 [结构体内] 所有车辆信息 */
void export_list(list_car* head) {list_car_sequence* prize_sequence_head=NULL, * seating_sequence_head=NULL, * output_sequence_head=NULL;if (head == NULL){printf("头指针为空!\n");return;}else {printf("车型\t厂商\t\t车型级别\t座位数\t排量\t变速箱\t车身颜色\t价格\n");printf("_______________________________________________________________________________________\n");for (; head != NULL; head = head->next) {printf("%s\t""%s\t""%s\t""%s座\t""%sT\t""%s\t""%s\t\t""%s万\n", head->imformation->type_of_name, head->imformation->manufacturer, head->imformation->model_class, head->imformation->seating_number, head->imformation->output_volume, head->imformation->transmission_case, head->imformation->color, head->imformation->prize);printf("\n");prize_sequence_head = list_prize_sequence(prize_sequence_head, head);seating_sequence_head = list_seating_sequence(seating_sequence_head, head);output_sequence_head = list_output_sequence(output_sequence_head, head);}}printf("从小到大类型:");getchar();char c;list_car_sequence* p;printf("1价格 2座位数 3排量 CTRL+Z退出 ");while (~(c = getchar())) {switch (c) {case '1':p = prize_sequence_head;break;case '2':p = seating_sequence_head;break;case '3':p = output_sequence_head;break;default:system("cls");printf("请重新输入:");goto loop;}if (p == NULL) {printf("没有信息!\n");return;}printf("_____________\n");for (;p != NULL;p = p->next,printf("\n"))printf("%s\t%s\n", p->name, p->imformation);getchar();loop:    printf("1价格 2座位数 3排量 CTRL+Z退出 ");}
}/******************************************************//*     输出  *//*************************************************************/
int main() {list_car* head = read_list_car();char x;printf("1为浏览所有信息 2为查询车辆具体信息 3录入新的车辆 4修改车辆信息 5为删除车辆信息 CTRL+Z为退出\n""请选择你想进行的功能:");while (~(x = getchar())) {system("cls");switch (x) {case '1':export_list(head);break;case '2':search(head);break;case '3':list_car_write(rear);break;case '4':list_car_alter(head);break;case '5':list_car_delete(head);break;default:printf("输入有误,请重新输入:\n");getchar();break;}system("cls");printf("1为浏览所有信息 2为查询车辆具体信息 3录入新的车辆 4修改车辆信息 5为删除车辆信息 CTRL+Z为退出\n""请选择你想进行的功能:");}write_list_car(head);return 0;
}​

C语言大作业:车辆管理系统相关推荐

  1. c语言大作业酒店管理系统,C语言酒店管理系统(最新整理)

    <C语言酒店管理系统(最新整理)>由会员分享,可在线阅读,更多相关<C语言酒店管理系统(最新整理)(7页珍藏版)>请在人人文库网上搜索. 1.include#include # ...

  2. c语言大作业车票管理系统,c语言车票管理系统.docx

    c语言车票管理系统 课 程 设 计 报 告课程名称 C语言课程设计 课题名称 车票管理系统 专 业 自动化 班 级 1402 学 号 201401020208 姓 名 宋爱军 指导教师 陈世清 杨子华 ...

  3. 中北大学c语言大作业网吧管理系统,中北大学图书管理系统.doc

    中北大学图书管理系统.doc 电子与计算机科学技术学院 数据结构课程设计 需 求 分 析 报 告 项目名称: 图书借阅管理系统 指导老师: 周海英 设计人员: 0座机电话号码6 周西财 日 期: 20 ...

  4. c语言大作业酒店管理系统,用C语言编写的酒店管理系统

    #include #include #include int max=1;//用于计数用户登录 int room[5][5];//声明一个2维数组保留每个房间的入住 int jishi[5][5];/ ...

  5. 学委作业管理系统c语言,c语言大作业-学生信息管理系统.doc

    c语言大作业-学生信息管理系统.doc 课程设计报告书 题目:学生信息管理系统设计 学 院 电子与信息学院 专 业 电子信息类 学生姓名 学生学号 指导教师 课程编号 135160 课程学分 1学分 ...

  6. C语言大作业:旅游资讯管理系统

    C语言大作业:旅游资讯管理系统 题目: 一.主体功能点要求: 1.设计主菜单实现用户交互 a.添加旅游资讯记录 每条记录至少包含如下项:编号.日程安排.费用.点赞数.添加旅游资讯记录时,要求键盘输入对 ...

  7. C语言总结项目和入门大作业——信息管理系统(多文件版)

    文章目录 八. C语言入门大作业--信息管理系统(多文件版) 一. 功能模块的划分: 二. 多文件的编写 三. 基本函数的实现(重点) 四.文件操作函数 五.函数的辅助函数 六.多文件编程和联系 七. ...

  8. 哈工大C语言大作业-学生成绩管理系统

    哈工大C语言大作业-学生成绩管理系统 完整项目地址:https://github.com/944613709/Student-Performance-Management-System-ByC 说明 ...

  9. 1008c语言答案,c语言大作业题目01008.doc

    c语言大作业题目01008 一.学生信息管理程序 基本要求: 1.要求实现学生信息的查找.添加.删除.修改.浏览.保存.从文件读取.查看奖学金信息8个功能,每个功能模块均能实现随时从模块中退出,而且可 ...

最新文章

  1. Python日志教程
  2. Android Activity的启动模式及对生命周期的影响
  3. android view 镜像,Android 实现镜像效果
  4. 对比了上百个python程序员的开发习惯,这10个方法最节省时间!
  5. Ext.apply与Ext.applyIf
  6. 拓端tecdat|“新媒体”和“社群”调查报告
  7. Jzoj3467 最长上升子序列
  8. WinRAR去广告方法,了解一下?
  9. TCP交互式游戏《基于TCP的C/S程序设计》
  10. 雷霄骅《视音频数据处理入门:H.264视频码流解析》(代码注释版)
  11. [haoi2009]毛毛虫 树形dp
  12. 【挨踢人物传】向立天:从电视编导到技术总监,只要努力,你也能铸就传奇(第七期)...
  13. Deprecated: Function eregi() is deprecated in ……【解决方法】
  14. wegame系统推荐头像_热点微信国旗头像刷屏,怎么回事?(附国旗获取方式)
  15. PTA - 厘米换算英尺英寸(C语言)
  16. SOFA原理学习--sofa rpc入门示例
  17. 2021数学建模国赛A题
  18. Ventrilo初学者指南,面向游戏玩家的VoIP应用
  19. 【poj1013】 Counterfeit Dollar
  20. CVE-2019-11477 SACK Panic漏洞利用分析

热门文章

  1. 解读IPD流程体系的“三驾马车”
  2. QT从零开始作单片机上位机-串口调试助手+波形显示-实现串口模块的配置
  3. linux音视频质量,linux好用的视频播放器
  4. 今天这教程难度有点高,反爬虫之跳过淘宝滑块验证!爬虫必会教程
  5. 戴好这六顶帽子的项目经理,无论项目团队还是个人成长都受益终生
  6. 奉加微采访 BLE
  7. PHP导出Excel耗尽内存,如何使用PHPExcel修复内存耗尽?
  8. Elasticsearch 的前世今生
  9. XDS100V3连接Pandaboard ES OMAP4460开发板
  10. 职称计算机 frontpage 2003,高会职称计算机《Frontpage 2003网页制作》全部开通