设为首页 加入收藏

TOP

用C写的停车收费代码(三)
2014-11-24 00:36:27 来源: 作者: 【 】 浏览:81
Tags:停车 收费 代码
,emi))
{
//start year month than end month indicate to park a month
sumday = sumday + StatisticsMonthDays(sy,sm,sd,sh,smi,ey,em,idx);
sm++;
if(sm >12)
{
sm = 1;
sy++;
}
idx++;
}
else if (CheckDay(sy,sm,sd,sh,smi,ey,em,ed,eh,emi))
{

sd++;
if(sd > GenerateMonth(sy)[sm])
{
sd = 1;
sm ++;
if(sm > 12)
{
sm = 1;
sy ++;
}
}
sumday = sumday ++;
}
else if(CheckHour(sy,sm,sd,sh,smi,ey,em,ed,eh,emi))
{
if(sh>=21 || sh<7 )
{
//night
sumhour_night = sumhour_night + StatisticsHour();
//all hour in night Times
if((eh >=21 || eh<7) && sd>ed && sh>eh || (eh >=21 || eh<7) && sd>ed && sh>=eh&& smi>=emi)
{
smi = 0;
}
sh=sh+2;
if(sh >= 7 && sh <9)
{
sh =7;
smi =0;
}
}
else
{
//day
sumhour_day = sumhour_day + StatisticsHour();
sh++;
if(sh>=21)
{
smi = 0;
}
}
if(sh >24)
{
if(sh == 25)
{
sh =1;
}
else
sh =2;
sd++;
if(sd > GenerateMonth(sy)[sm])
{
sd = 1;
sm++;
if(sm >12)
{
sm = 1;
sy ++;
}
}
}

}
else if(ey>=sy && em>=sm && ed>=sd && eh >=sh )
{
if(smi >60)
{
smi = smi%60;
sh++;
}
summinute = summinute++;
smi = smi+Per_time;
}
else
{
break;
}
}

printf("The Car is parking %d days and approximate %d hours of day \n and approximate %d hours of night and approximate %d minutes \n",sumday,sumhour_day,sumhour_night,summinute*Per_time);
StatisticsCost( sumday,sumhour_night,sumhour_day,summinute,car_type);
return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{

//start yyyy mmm dd hh24 mi and car_type
int sy,sm,sd,sh,smi,car_type;
//end yyyy mmm dd hh24 mi and car_type
sy=sm=sd=sh=smi=car_type = 0;
int ey,em,ed,eh,emi;
ey=em=ed=eh=emi = 0;
int result =0;
printf("Please input to park car start time,format is yyyy mm dd hh24 mi \n");
scanf("%d %d %d %d %d",&sy,&sm,&sd,&sh,&smi);
printf("Please input to park car type,when 1 then small car when 2 big car else 1 \n");
scanf("%d",&car_type);

printf("Please input to park car start time,format is yyyy mm dd hh24 mi \n");
scanf("%d %d %d %d %d",&ey,&em,&ed,&eh,&emi);
///////////////////////////////////////////
if(Compare(sy,sm,sd,sh,smi,ey,em,ed,eh,emi))
{
//input correctly
printf("[ Parking car charge standard! \n");
printf("Start 7 to 21 per %d minutes bigCar is %d and smallCar is %f \n",Per_time,Bigcar_rule,Smallcar_rule);
printf("Pass an Hour per %d minutes bigCar is %f and smallCar is %f \n",Per_time,Bigcar_att,Smallcar_att);
printf("Start 21 to 7 per 2 hours bigCar is %d and smallCar is %d ] \n",Bigcar_night,Smallcar_night);
printf("\n");
time_t lt;
lt = time(NULL);
printf("%s\n",ctime(<));
result = StatisticsTime(sy,sm,sd,sh,smi,ey,em,ed,eh,emi,car_type);
time_t et;
et=time(NULL);
printf("%s\n",ctime(&et));
printf("%d",ctime(&et) - ctime(<));
}
else
{
printf("Input error please check your input value");
}
scanf("%d") ;
//printf("%d %d %d %d %d",y,m,d,h,mi);

return 0;
}


摘自 sql_xep的专栏
首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇AVL树单旋转和双旋转算法(c) 下一篇C语言学习之控制语句

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: