车辆违章管理信息系统c语言
时间: 2023-12-21 17:30:46 浏览: 204
车辆违章管理信息系统是一个用于管理车辆违章信息的系统,下面是一个基于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);
}
```
阅读全文