当前位置:首页 » 编程语言 » 租车c语言

租车c语言

发布时间: 2022-02-28 14:43:59

‘壹’ 汽车租赁系统的c语言,数据结构的语言程序

刚写完,好累.还有很多bug,你看看会不会改,不行的话我有时间再帮你改.各位有什么意见的也可以告诉我

编译器是VC6

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MaxNum 20

typedef struct A{
int No; /*车辆编号*/
char Type; /*车类型*/
int Payment;/*租费*/
int fine; /*罚金*/
struct A *next;/*指向下一个结点*/
} car;

typedef struct B{
int No; /*顾客编号*/
char Name[20]; /*顾客姓名*/
char License; /*执照类别*/
int carNo; /*租凭的车辆编号*/
int Day; /*租的天数*/
int DelayDay;/*延迟的天数*/
struct B *next;
} client;

struct C{/*这个结构体是车辆链表的头结点,A,B,C每种类型有一种*/
char Type;/*车辆型号*/
int avl; /*可用数*/
car *head;/*指向车辆结点*/
} headNode[3]={{'A',MaxNum,NULL},{'B',MaxNum,NULL},{'C',MaxNum,NULL}} ;

client *allClien=NULL;
int pay[3]={400,300,200},fine[3]={600,500,400};
void init();/*初始化*/
int menu();/*简单菜单界面*/
void search();/*查询*/
void carSc(); /*查询车辆*/
void clientSc();/*查询顾客*/
void rent(); /*租车*/
void giveback();/*还车*/
void addCli(client *cli);/*向顾客链表增加顾客*/
client* delCli(int clientNo);/*从顾客链表删除一个顾客*/
void addCar();/*向车辆链表归还车辆*/
car* delCar();/*从车辆链表拿出一辆车*/
void Exit();/*退出*/

void main()
{
init();
while(1)
{
switch(menu())
{
case 1:search();break;
case 2:rent();break;
case 3:giveback();break;
case 4:Exit();
default:;
}
}
}

void init()
{
int i;
car *ptr,*pa=headNode[0].head,*pb=headNode[1].head,*pc=headNode[2].head;
for(i=1;i<=MaxNum;i++)
{
ptr=(car *)malloc(sizeof(car));
ptr->No=100+i;
ptr->Type='A';
ptr->Payment=400;
ptr->fine=600;
pa=ptr;
pa=ptr->next;

ptr=ptr=(car *)malloc(sizeof(car));
ptr->No=200+i;
ptr->Type='B';
ptr->Payment=300;
ptr->fine=500;
pb=ptr;
pb=ptr->next;

ptr=(car *)malloc(sizeof(car));
ptr->No=300+i;
ptr->Type='C';
ptr->Payment=200;
ptr->fine=400;
pc=ptr;
pc=ptr->next;
}
pa=NULL;pb=NULL;pc=NULL;
}

int menu()
{
int choice;

printf("\n\n\n选择服务:1.查询 2.租车 3.归还 4.退出\n");

scanf("%d",&choice);

while(choice!=1&&choice!=2&&choice!=3&&choice!=4)
{
printf("\n输入有误,重新输入:");
scanf("%d",&choice);
}
return choice;
}

void search()
{
int choice;
printf("\n你想查询:1.汽车 2.顾客 3.返回 \n");
scanf("%d",&choice);

while(choice!=1&&choice!=2&&choice!=3)
{
printf("\n输入有误,重新输入:");
scanf("%d",&choice);
}

switch(choice)
{
case 1:carSc(); break;
case 2:clientSc(); break;
case 3: ;
default:;
}
}

void carSc()
{
printf("\n\n所有汽车信息:\n");
printf("\nA类汽车还剩%d辆.\nB类汽车还剩%d辆.\nC类汽车还剩%d辆.",
headNode[0].avl,headNode[1].avl,headNode[2].avl);

}

void clientSc()
{
client *ptr=allClien;
printf("\n\n所有顾客信息:\n");

while(ptr!=NULL)
{ printf("\n\n顾客编号:%d",ptr->No);
printf("\n顾客姓名:%s",ptr->Name);
printf("\n驾照类型:%c",ptr->License);
printf("\n租赁车号:%d",ptr->carNo);
printf("\n租赁天数:%d",ptr->Day);
printf("\n延迟天数:%d",ptr->DelayDay);

ptr=ptr->next;
}
}

void addCli(client *cli)
{
if(allClien)
allClien=cli;
else
{
cli->next=allClien->next;
allClien=cli;
}
}

client* delCli(int clientNo)
{
client *ptr,*prePtr;;
ptr=allClien;
while(ptr!=NULL&&ptr->No!=clientNo)
{ prePtr=ptr;
ptr=ptr->next;
}
if(ptr!=NULL)
{
if(ptr==allClien)
{
allClien=NULL;
}
else
{
prePtr->next=ptr->next;
}
}
return ptr;
}

void rent()
{
char name[20],type,Yes_No;
int num,day,No;
car *carPtr;
client *cli;

printf("\n\n输入执照类型(A/B/C):");
scanf("%c",&type);
while(type!='A'&&type!='B'&&type!='C')
{
printf("输入有误,重新输入:");
scanf("%c",&type);
}
if(type=='A')
num=headNode[0].avl;
else if(type=='B')
num=headNode[1].avl;
else
num=headNode[2].avl;

printf("\n%c类汽车还剩%d辆,是否要租凭(Y/N):",type,num);
scanf("%c",&Yes_No);
while(Yes_No!='Y'&&Yes_No!='N'&&Yes_No!='y'&&Yes_No!='n')
{
printf("Y或N:");
scanf("%c",&Yes_No);
}

/*增加顾客*/
if(Yes_No=='Y'||Yes_No=='y')
{
printf("\n输入你的名字:");
scanf("%s",name);

printf("\n输入你的租赁天数:");
scanf("%d",&day);
}
No=rand()%60+200;
carPtr=delCar(type);

cli=(client *)malloc(sizeof(client));
cli->No=No;
strcpy(cli->Name,name);
cli->License=type;
cli->carNo=carPtr->No;
cli->Day=day;
cli->DelayDay=0;
cli->next=NULL;
addCli(cli);

/*移出一辆车*/
printf("\n你的顾客编号是:%d",No);
printf("\n你所租赁的汽车是%c类车,车号是:%d",type,carPtr->No);
printf("\n你的租赁天数是%d天.",day);

}

void giveback()
{
int No;
long int payment;
client *ptr;
printf("\n\n顾客编号:");
scanf("%d",&No);
if((ptr=delCli(No))==NULL)
printf("\n该顾客不存在,无法归还!");
else
{
switch(ptr->License)
{
case 1:payment=ptr->Day*400+ptr->DelayDay*600;break;
case 2:payment=ptr->Day*300+ptr->DelayDay*500;break;
case 3:payment=ptr->Day*200+ptr->DelayDay*400;break;
default:;
}
printf("\n\n顾客姓名:%s",ptr->Name);
printf("\n驾照类型:%c",ptr->License);
printf("\n租赁车号:%d",ptr->carNo);
printf("\n租赁天数:%d",ptr->Day);
printf("\n延迟天数:%d",ptr->DelayDay);
printf("\n\n所需费用:%ld",payment);

addCar(ptr->License,ptr->carNo);

free(ptr);
}

}

void addCar(char carType,int carNo)
{
car *ptr;
int index=carType-65;
ptr=headNode[index].head;
if(ptr==NULL)
{ptr=(car *)malloc(sizeof(car));
headNode[index].head=ptr;
}
else
{while(ptr->next)
ptr=ptr->next;
ptr->next=(car *)malloc(sizeof(car));
ptr=ptr->next;
}
ptr->No=carNo;
ptr->Type=carType;
ptr->Payment= pay[index];
ptr->fine=fine[index];
ptr->next=NULL;
}

car* delCar(char type)
{
car *rentcar;

switch(type)
{
case 'A':rentcar=headNode[0].head;
headNode[0].head=rentcar->next;
break;
case 'B':rentcar=headNode[1].head;
headNode[1].head=rentcar->next;
break;
case 'C':rentcar=headNode[2].head;
headNode[2].head=rentcar->next;
break;
default:;
}
return rentcar;

}

void Exit()
{

printf("\n欢迎使用.....888888888886666....");
exit(0);
}

‘贰’ C语言车租车问题

#include <stdio.h>
void main()
{
int km;float m;
printf(“please enter your distance.”);
scanf(“%d”,&km);
if(km<=8)m=10;
else if(km<=10)m=10+(km-8)*1.6;
else if(km<=15)m=10+3.2+(km-10)*2.5;
else m=10+3.2+12.5+(km-15)*3;
printf(“your should pay %d”,m);
}

‘叁’ 用C语言要写,出租车收费,3公里内收5元,超3公里部分每公收1.2元。

#include<stdio.h>
intmain()
{
inta;
floatv;
scanf("%d",&a);
if(a<=3)v=5;
elsev=5+1.2*(v-3);
printf("%.1f ",v);
return0;
}

‘肆’ 求一汽车租赁的编程,用C语言(急……)

刘黎志老师知道

‘伍’ 用C语言编写汽车租赁系统

考察点就是结构体,用数组或者链表都可以搞定。
我也可以帮你哈

‘陆’ C语言编程:请编出租车计费程序

#include
"iostream"
using
namespace
std;
int
main()
{
int
index;
double
per;
double
qibu;
int
kilometre;
double
pay
=
0;
cout
<<"输入里程数(公里):";
cin
>>
kilometre;
cout
<<"选择车辆:1.桑塔纳
2.夏利"<<endl;
cin>>index;
if(index==1)
{
per
=
2.7;
qibu
=
4;
}
else
{
per
=
2.1;
qibu=3;
}
if(kilometre>3)
pay
=
qibu
+
(kilometre-3)*per;
else
pay
=
qibu;
cout
<<"总价为:"<<pay<<endl;
return
0;
}
你也可以用结构数组来保存单价和起步费

‘柒’ C语言编程:出租车计费

“每5分钟按1公里租费”这里的1公里租费你没有说清,我按照2元每公里算的,程序如下:
#include
"stdio.h"
int
main(int
argc,
char*
argv[])
{
int
length,time,sum;
start:
printf("请输入行驶里程(公里):");
scanf("%d",&length);
printf("请输入等待时间(分钟):");
scanf("%d",&time);
if(length<0||time<0)
{
printf("行驶里程和等待时间不能为负数!\n");
goto
start;
}
else
if(length<=3)
{
sum=10;
}
else
if(length<=13)
{
sum=10+(length-3)*2;
}
else
sum=10+10*2+(length-13)*3;
sum=sum+(int)(time*(0.4));
//等待的每分钟0.4元
printf("乘客应支付的车费(元):\t%d\n",sum);
return
0;
}

‘捌’ C语言 出租车收费标准

#include<stdlib.h>
#include<stdio.h>
int main(void)
{
float money,road,time;
printf("input road and time:\n");
scanf("%f%f",&road,&time);//少了个 %号
if(road<=3)
money=10;
else if(road<=10)
money=10+2*(road-3)+time/5*2;
else
money=10+2*7+(road-10)*3+time/5*3;
printf(" money =%.0f\n ",money);//输出 单位为元,不含小数
system("pause");
return 0;
}

‘玖’ c语言编程 汽车租赁问题

亲测可以运行 自己的课程设计 搞得很累 代码如下我的课程设计 汽车租赁系统c语言

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MaxNum 20

typedef struct A{
int No; /*车辆编号*/
char Type; /*车类型*/
int Payment;/*租费*/
int fine; /*罚金*/
struct A *next;/*指向下一个结点*/
} car;

typedef struct B{
int No; /*顾客编号*/
char Name[20]; /*顾客姓名*/
char License; /*执照类别*/
int carNo; /*租凭的车辆编号*/
int Day; /*租的天数*/
int DelayDay;/*延迟的天数*/
struct B *next;
} client;

struct C{/*这个结构体是车辆链表的头结点,A,B,C每种类型有一种*/
char Type;/*车辆型号*/
int avl; /*可用数*/
car *head;/*指向车辆结点*/
} headNode[3]={{'A',MaxNum,NULL},{'B',MaxNum,NULL},{'C',MaxNum,NULL}} ;

client *allClien=NULL;
int pay[3]={400,300,200},fine[3]={600,500,400};
void init();/*初始化*/
int menu();/*简单菜单界面*/
void search();/*查询*/
void carSc(); /*查询车辆*/
void clientSc();/*查询顾客*/
void rent(); /*租车*/
void giveback();/*还车*/
void addCli(client *cli);/*向顾客链表增加顾客*/
client* delCli(int clientNo);/*从顾客链表删除一个顾客*/
void addCar(char carType,int carNo);
car* delCar(char type);
void Exit();/*退出*/

void main()
{
init();
while(1)
{
switch(menu())
{
case 1:search();break;
case 2:rent();break;
case 3:giveback();break;
case 4:Exit();
default:;
}
}
}

void init()
{
int i=0;
car *ptr,*pa,*pb,*pc;
headNode[0].head=NULL,headNode[1].head=NULL,headNode[2].head=NULL;

ptr=(car *)malloc(sizeof(car));
ptr->No=100;
ptr->Type='A'
ptr->Payment=400;
ptr->fine=600;
headNode[0].head=ptr;
pa=ptr;
pa->next=NULL;

for( i=1;i<20;i++){
ptr=(car *)malloc(sizeof(car));
ptr->No=100+i;
ptr->Type='A'
ptr->Payment=400;
ptr->fine=600;
pa->next=ptr;
pa=ptr;
pa->next=NULL;

}
free(ptr);

ptr=(car *)malloc(sizeof(car));
ptr->No=200;
ptr->Type='B'
ptr->Payment=300;
ptr->fine=500;
headNode[1].head=ptr;
pb=ptr;
pb->next=NULL;

for( i=1;i<20;i++){
ptr=(car *)malloc(sizeof(car));
ptr->No=200+i;
ptr->Type='A'
ptr->Payment=400;
ptr->fine=600;
pb->next=ptr;
pb=ptr;
pb->next=NULL;

}
free(ptr);


ptr=(car *)malloc(sizeof(car));
ptr->No=300;
ptr->Type='C'
ptr->Payment=200;
ptr->fine=400;
headNode[2].head=ptr;
pc=ptr;
pc->next=NULL;

for( i=1;i<20;i++){
ptr=(car *)malloc(sizeof(car));
ptr->No=300+i;
ptr->Type='A'
ptr->Payment=400;
ptr->fine=600;
pc->next=ptr;
pc=ptr;
pc->next=NULL;

}
free(ptr);
}

int menu()
{
int choice;

printf(" 选择服务:1.查询 2.租车 3.归还 4.退出 ");

scanf("%d",&choice);

while(choice!=1&&choice!=2&&choice!=3&&choice!=4)
{
printf(" 输入有误,重新输入:");
scanf("%d",&choice);
}
return choice;
}

void search()
{
int choice;
printf(" 你想查询:1.汽车 2.顾客 3.返回 ");
scanf("%d",&choice);

while(choice!=1&&choice!=2&&choice!=3)
{
printf(" 输入有误,重新输入:");
scanf("%d",&choice);
}

switch(choice)
{
case 1:carSc(); break;
case 2:clientSc(); break;
case 3: ;
default:;
}
}

void carSc()
{
printf(" 所有汽车信息: ");
printf(" A类汽车还剩%d辆. B类汽车还剩%d辆. C类汽车还剩%d辆.",
headNode[0].avl,headNode[1].avl,headNode[2].avl);

}

void clientSc()
{
client *ptr=allClien;
printf(" 所有顾客信息: ");

while(ptr!=NULL)
{ printf(" 顾客编号:%d",ptr->No);
printf(" 顾客姓名:%s",ptr->Name);
printf(" 驾照类型:%c",ptr->License);
printf(" 租赁车号:%d",ptr->carNo);
printf(" 租赁天数:%d",ptr->Day);
printf(" 延迟天数:%d",ptr->DelayDay);

ptr=ptr->next;
}
}

void addCli(client *cli)
{
if(allClien==NULL)
allClien=cli;
else
{
cli->next=allClien;
allClien=cli;
}
}

client* delCli(int clientNo)
{
client *ptr,*prePtr;;
ptr=allClien;
while(ptr!=NULL&&ptr->No!=clientNo)
{ prePtr=ptr;
ptr=ptr->next;
}
if(ptr!=NULL)
{
if(ptr==allClien)
{
allClien=NULL;
}
else
{
prePtr->next=ptr->next;
}
}
return ptr;
}

void rent()
{
char name[20],type,Yes_No;
int num,day,No;
car *carPtr;
client *cli;

printf(" 输入执照类型(A/B/C):");
scanf("%c",&type);
while(type!='A'&&type!='B'&&type!='C')
{
printf("输入有误,重新输入:");
scanf("%c",&type);
}
if(type=='A')
num=headNode[0].avl;
else if(type=='B')
num=headNode[1].avl;
else
num=headNode[2].avl;

printf(" %c类汽车还剩%d辆,是否要租凭(Y/N):",type,num);
scanf("%c",&Yes_No);
while(Yes_No!='Y'&&Yes_No!='N'&&Yes_No!='y'&&Yes_No!='n')
{
printf("Y或N:");
scanf("%c",&Yes_No);
}

/*增加顾客*/
if(Yes_No=='Y'||Yes_No=='y')
{
printf(" 输入你的名字:");

scanf("%s",name);

printf(" 输入你的租赁天数:");
scanf("%d",&day);
}
No=rand()%60+200;
carPtr=delCar(type);

cli=(client *)malloc(sizeof(client));
cli->No=No;
strcpy(cli->Name,name);
cli->License=type;
cli->carNo=carPtr->No;
cli->Day=day;
cli->DelayDay=0;
cli->next=NULL;
addCli(cli);

/*移出一辆车*/
printf(" 你的顾客编号是:%d",No);
printf(" 你所租赁的汽车是%c类车,车号是:%d",type,carPtr->No);
printf(" 你的租赁天数是%d天.",day);

}

void giveback()
{
int No;
long int payment;
client *ptr;
printf(" 顾客编号:");
scanf("%d",&No);
if((ptr=delCli(No))==NULL)
printf(" 该顾客不存在,无法归还!");
else
{
switch(ptr->License)
{
case 1:payment=ptr->Day*400+ptr->DelayDay*600;break;
case 2:payment=ptr->Day*300+ptr->DelayDay*500;break;
case 3:payment=ptr->Day*200+ptr->DelayDay*400;break;
default:;
}
printf(" 顾客姓名:%s",ptr->Name);
printf(" 驾照类型:%c",ptr->License);
printf(" 租赁车号:%d",ptr->carNo);
printf(" 租赁天数:%d",ptr->Day);
printf(" 延迟天数:%d",ptr->DelayDay);
printf(" 所需费用:%ld",payment);

addCar(ptr->License,ptr->carNo);

free(ptr);
}

}

void addCar(char carType,int carNo)
{
car *ptr;
int index=carType-65;
ptr=headNode[index].head;
if(ptr==NULL)
{ptr=(car *)malloc(sizeof(car));
headNode[index].head=ptr;
headNode[index].avl++;
}
else
{while(ptr->next)
ptr=ptr->next;
ptr->next=(car *)malloc(sizeof(car));
ptr=ptr->next;
headNode[index].avl++;
}
ptr->No=carNo;
ptr->Type=carType;
ptr->Payment= pay[index];
ptr->fine=fine[index];
ptr->next=NULL;
}

car* delCar(char type)
{
car *rentcar;
car *pp;

switch(type)
{
case 'A':
rentcar=headNode[0].head;
headNode[0].head=rentcar->next;
headNode[0].avl--;

break;
case 'B':rentcar=headNode[1].head;
headNode[1].head=rentcar->next;
headNode[1].avl--;
break;
case 'C':rentcar=headNode[2].head;
headNode[2].head=rentcar->next;
headNode[2].avl--;
break;
default:;
}
return rentcar;

}

void Exit()
{

printf(" 欢迎使用.....888888888886666....");
exit(0);
}

‘拾’ 用C语言写一租车管理系统

这个太简单了。。。我都不想说了。用双向链表就可以轻松实现,自己花时间看一看《数据结构》吧。连脑子都不想动,还学个蛋蛋C语言....

热点内容
云服务器容灾 发布:2025-01-11 11:51:40 浏览:681
phparraysplice 发布:2025-01-11 11:51:40 浏览:319
android学习源码 发布:2025-01-11 11:26:23 浏览:412
服务器都坏了如何恢复 发布:2025-01-11 11:24:04 浏览:353
微博缓存的图片能清理吗 发布:2025-01-11 11:01:49 浏览:307
文字加密器 发布:2025-01-11 11:01:08 浏览:453
vc60非静态编译 发布:2025-01-11 10:51:32 浏览:615
电脑上怎么解压缩文件 发布:2025-01-11 10:51:31 浏览:784
枪战王者如何用账号密码登录 发布:2025-01-11 10:30:56 浏览:938
mysql在linux下安装 发布:2025-01-11 10:30:49 浏览:845