c语言车辆违规信息管理系统
时间: 2023-11-12 15:07:19 浏览: 36
车辆违规信息管理系统是一种基于信息技术的现代化管理方式。它可以通过车牌号查询每台车辆的违章情况,也可以统计每台车辆的罚款总金额。为了实现这个功能,可以设计一个车辆信息的结构体,其中包括车牌号、车主姓名、违章时间、违章地点、违章情况和处罚情况等信息。引入车辆违章信息管理系统可以提高工作效率,支持信息共享,减轻管理部门的负担,给普通用户带来了方便。同时,这种系统还具有可扩展性、快捷性、性价比高和易于维护等优势。
相关问题
c语言车辆违章管理系统
C语言车辆违章管理系统可以通过使用结构体和数组来实现。以下是一个简单的示例:
```c
#include <stdio.h>
#include <string.h>
#define MAX_SIZE 100
typedef struct {
char id[MAX_SIZE]; // 编号
char carId[MAX_SIZE]; // 车牌号
char name[MAX_SIZE]; // 车主姓名
char sex[MAX_SIZE]; // 性别
char violateTime[MAX_SIZE]; // 违章时间
char address[MAX_SIZE]; // 违章地点
char situation[MAX_SIZE]; // 违章情况
char punish[MAX_SIZE]; // 处罚情况
} CarInfo;
typedef struct {
char carId[MAX_SIZE]; // 车牌号
char driverName[MAX_SIZE]; // 驾驶员姓名
char policeName[MAX_SIZE]; // 交警姓名
char policeId[MAX_SIZE]; // 交警编号
char ticketId[MAX_SIZE]; // 交通处罚单编号
char punishDate[MAX_SIZE]; // 处罚日期
} PunishInfo;
int main() {
CarInfo carInfos[MAX_SIZE];
PunishInfo punishInfos[MAX_SIZE];
int carCount = 0;
int punishCount = 0;
// 添加车辆信息
strcpy(carInfos[carCount].id, "001");
strcpy(carInfos[carCount].carId, "粤A12345");
strcpy(carInfos[carCount].name, "张三");
strcpy(carInfos[carCount].sex, "男");
strcpy(carInfos[carCount].violateTime, "2021-01-01");
strcpy(carInfos[carCount].address, "广州市");
strcpy(carInfos[carCount].situation, "闯红灯");
strcpy(carInfos[carCount].punish, "罚款100元");
carCount++;
// 添加处罚单信息
strcpy(punishInfos[punishCount].carId, "粤A12345");
strcpy(punishInfos[punishCount].driverName, "张三");
strcpy(punishInfos[punishCount].policeName, "李四");
strcpy(punishInfos[punishCount].policeId, "001");
strcpy(punishInfos[punishCount].ticketId, "20210101001");
strcpy(punishInfos[punishCount].punishDate, "2021-01-01");
punishCount++;
// 查询车辆违章情况
char searchCarId[MAX_SIZE];
printf("请输入要查询的车牌号:");
scanf("%s", searchCarId);
for (int i = 0; i < carCount; i++) {
if (strcmp(carInfos[i].carId, searchCarId) == 0) {
printf("车辆违章情况:\n");
printf("车牌号:%s\n", carInfos[i].carId);
printf("违章时间:%s\n", carInfos[i].violateTime);
printf("违章地点:%s\n", carInfos[i].address);
printf("违章情况:%s\n", carInfos[i].situation);
printf("处罚情况:%s\n", carInfos[i].punish);
break;
}
}
// 统计车辆罚款总金额
char searchCarId2[MAX_SIZE];
printf("请输入要统计罚款总金额的车牌号:");
scanf("%s", searchCarId2);
int totalFine = 0;
for (int i = 0; i < carCount; i++) {
if (strcmp(carInfos[i].carId, searchCarId2) == 0) {
int fine = atoi(strtok(carInfos[i].punish, "罚款"));
totalFine += fine;
}
}
printf("车辆罚款总金额:%d元\n", totalFine);
return 0;
}
```
车辆违章管理信息系统c语言
车辆违章管理信息系统是一个用于管理车辆违章信息的系统,下面是一个基于C语言的简单实现:
1. 添加车辆信息
```c
void addCarInfo(CarInfo car[], int *count) {
printf("请输入车辆信息:\n");
printf("车牌号:");
scanf("%s", car[*count].carId);
printf("车主姓名:");
scanf("%s", car[*count].name);
printf("性别:");
scanf("%s", car[*count].sex);
printf("违章时间:");
scanf("%s", car[*count].violateTime);
printf("违章地点:");
scanf("%s", car[*count].address);
printf("违章情况:");
scanf("%s", car[*count].situation);
printf("处罚情况:");
scanf("%s", car[*count].punish);
(*count)++;
printf("添加成功!\n");
}
```
2. 查询车辆违章信息
```c
void queryCarInfo(CarInfo car[], int count) {
char carId[maxsize];
printf("请输入要查询的车牌号:");
scanf("%s", carId);
int flag = 0;
for (int i = 0; i < count; i++) {
if (strcmp(car[i].carId, carId) == 0) {
printf("车牌号:%s\n", car[i].carId);
printf("车主姓名:%s\n", car[i].name);
printf("性别:%s\n", car[i].sex);
printf("违章时间:%s\n", car[i].violateTime);
printf("违章地点:%s\n", car[i].address);
printf("违章情况:%s\n", car[i].situation);
printf("处罚情况:%s\n", car[i].punish);
flag = 1;
}
}
if (!flag) {
printf("未查询到该车辆违章信息!\n");
}
}
```
3. 统计车辆罚款总金额
```c
void countFine(CarInfo car[], int count) {
char carId[maxsize];
printf("请输入要统计罚款总金额的车牌号:");
scanf("%s", carId);
int totalFine = 0;
for (int i = 0; i < count; i++) {
if (strcmp(car[i].carId, carId) == 0) {
int fine = 0;
for (int j = 0; j < strlen(car[i].punish); j++) {
if (car[i].punish[j] >= '0' && car[i].punish[j] <= '9') {
fine = fine * 10 + car[i].punish[j] - '0';
}
}
totalFine += fine;
}
}
printf("车牌号为%s的车辆罚款总金额为%d元。\n", carId, totalFine);
}
```