main()
{
float allsecond;
int type;
int run_hour,run_second,run_day,run_month,run_year,run_minute;
int end_year,end_month,end_day,end_hour,end_minute,end_second;
float sum,near,far,IP,sa,sb;
printf("input start time:\n");
printf("start year:");
scanf("%d",&run_year);
printf("start month:");
scanf("%d",&run_month);
printf("start day:");
scanf("%d",&run_day);
printf("start hour:");
scanf("%d",&run_hour);
printf("start minute:");
scanf("%d",&run_minute);
printf("start second:");
scanf("%d",&run_second);
printf("input end time:\n");
printf("end year:");
scanf("%d",&end_year);
printf("end month:");
scanf("%d",&end_month);
printf("end day:");
scanf("%d",&end_day);
printf("end hour:");
scanf("%d",&run_hour);
printf("end minute:");
scanf("%d",&end_minute);
printf("end second:");
scanf("%d",&end_second);
allsecond=
(run_year*31536000+run_month*2678400+run_day*86400+run_hour*3600+run_minute*60+run_second)-
(end_year*31536000+end_month*2678400+end_day*86400+end_hour*3600+end_minute*60+end_second);
if(run_hour<=7&&run_hour>0)
{
if(allsecond<=180) sa=0.22*allsecond/60;
else if(allsecond>180) sb=0.22*3+0.11*(allsecond-180)/60;
near=(sa+sb)/2;
far=(0.07*allsecond/6)/2;
IP=(0.03*allsecond/6+near)/2; }
else if(run_hour>7&&run-hour<=24)
{near=sa+sb;
far=0.07*allsecond/6;
IP=0.03*allsecond/6+near;}
printf("input tel type(1 2 3 4):");
scanf("%d",&type);
switch(type)
{case 1:sum=near;break;
case 2:sum=far;break;
case 3:sum=IP;break;
case 4:sum=far+IP;break;}
printf("cost is %f",sum);
}
[此贴子已经被作者于2007-7-16 3:27:26编辑过]