145 - Gondwanaland Telecom

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

junbin
Experienced poster
Posts: 174
Joined: Mon Dec 08, 2003 10:41 am

Post by junbin »

make sure you handle the following cases:

1) Calls that go across midnight (eg: 2300 to 0200)
2) Calls that go exactly 24 hours (eg: 0400 to 0400)

Also, check your floating point numbers.

El-idioto
New poster
Posts: 45
Joined: Mon Jul 14, 2003 9:42 pm
Location: Zoetermeer, The Netherlands

Post by El-idioto »

I most certainly handle those correctly.

Do you have an AC app?
I would like to test my WA app against your app using brute force.
There are only 1440^2 possibilities (per charging step). :roll:

I tested a couple of thousand cases already without finding any problem. :(

El-idioto
New poster
Posts: 45
Joined: Mon Jul 14, 2003 9:42 pm
Location: Zoetermeer, The Netherlands

Post by El-idioto »

:evil: :o :x I now know what my problem was!!! :evil: :o :x

The scanf function (which I don't know all that well) differs from the printf function (which I know really well).

I always use printf("%i", 5);
I never use printf("%d", 5);

In printf, these two lines do exactly the same thing.

In scanf, the first line not only means 'integer', but also 'octal' and 'hexadecimal' :evil: :evil: :evil:

Anyway, I changed all the projects which were vulnerable (I had a LOT of %i).
I'm REALLY lucky I got through with all my previous solutions!!!

oulongbin
Learning poster
Posts: 53
Joined: Sat Jul 10, 2004 5:57 pm
Location: Shanghai China

145 WA thanx

Post by oulongbin »

plz help me ,thanx!
[cpp]
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>

int main()
{
char dis;
char l[50];
char tnb[8];
int starth,startm,endh,endm;
int stime,etime;
int time[1441];
int d,e,n;
int i;
double money,day,evening,night;
while(cin.getline(l,50)&&l[0]!='#')
{
dis=l[0];
tnb[0]=l[2];
tnb[1]=l[3];
tnb[2]=l[4];
tnb[3]=l[5];
tnb[4]=l[6];
tnb[5]=l[7];
tnb[6]=l[8];
tnb[7]=l[9];
starth=(int(l[11])-48)*10+int(l[12])-48;
startm=(int(l[14])-48)*10+int(l[15])-48;
endh=(int(l[17])-48)*10+int(l[18])-48;
endm=(int(l[20])-48)*10+int(l[21])-48;

/*cin>>dis;
if(dis=='#')
break;
for(i=0;i<7;i++)
cin>>tnb;
cin>>starth>>startm>>endh>>endm;*/
for(i=1;i<1441;i++)
time=0;
d=e=n=0;
money=0;

switch(dis)
{
case 'A':{day=0.1;evening=0.06;night=0.02;break;}
case 'B':{day=0.25;evening=0.15;night=0.05;break;}
case 'C':{day=0.53;evening=0.33;night=0.13;break;}
case 'D':{day=0.87;evening=0.47;night=0.17;break;}
case 'E':{day=1.44;evening=0.8;night=0.3;break;}
}
//cout<<day<<" "<<evening<<" "<<night<<endl;
stime=60*starth+startm;
etime=60*endh+endm;
//cout<<stime<<endl<<etime<<endl;
if(stime<=etime)
{
for(i=stime+1;i<=etime;i++)
{
time=1;
}
}
else
{
for(i=1;i<=etime;i++)
time=1;
for(i=stime+1;i<=1440;i++)
time=1;
}
for(i=1;i<=480;i++)
n+=time;
for(i=481;i<=1080;i++)
d+=time;
for(i=1081;i<=1320;i++)
e+=time;
for(i=1321;i<=1440;i++)
n+=time;
//cout<<day<<" "<<evening<<" "<<night<<endl;
//cout<<d<<" "<<e<<" "<<n<<endl;
money=day*d+evening*e+night*n;
//cout<<money<<endl;
cout<<" ";
for(i=0;i<8;i++)
cout<<tnb;
printf("%6d%6d%6d%3c%8.2f\n",d,e,n,dis,money);
}
return 0;
}
[/cpp]

Zhls
New poster
Posts: 9
Joined: Sat Oct 16, 2004 2:14 pm

***145 Gondwanaland Telecom***Why I get a P.E???

Post by Zhls »

Why I get PE on the pro.145?
I have check my output format again and again.
But I don't find the bug!
So I hope you can help me, Thank you.....
My code is as :

Code: Select all

[cpp]
#include <iostream.h>
#include <iomanip.h>

double dayCost[5] = {86.40, 216.00, 475.20, 736.80, 1236.00};
double charge[5][3] = 
{
	{0.10, 0.06, 0.02},
	{0.25, 0.15, 0.05},
	{0.53, 0.33, 0.13},
	{0.87, 0.47, 0.17},
	{1.44, 0.80, 0.30}
};
int minutes[3];

double getCost(int start, int end, int type)
{
	if (start<480)
	{
		if (end<=480)
		{
			minutes[2] = end - start;
			return (charge[type][2]*minutes[2]);
		}
		else if (end<=1080)
		{
			minutes[2] = 480 - start;
			minutes[0] = end - 480;
			return (charge[type][2]*minutes[2]+charge[type][0]*minutes[0]);
		}
		else if (end<=1320)
		{
			minutes[2] = 480 - start;
			minutes[0] = 600;
			minutes[1] = end - 1080;
			return (charge[type][2]*minutes[2]+charge[type][0]*minutes[0]+charge[type][1]*minutes[1]);
		}
		else if (end<=1440)
		{
			minutes[2] = 480 - start + end - 1320;
			minutes[0] = 600;
			minutes[1] = 240;
			return (charge[type][2]*minutes[2]+charge[type][0]*minutes[0]+charge[type][1]*minutes[1]);
		}
	}
	else if (start<1080)
	{
		if (end<=1080)
		{
			minutes[0] = end - start;
			return (charge[type][0]*minutes[0]);
		}
		else if (end<=1320)
		{
			minutes[0] = 1080 - start;
			minutes[1] = end - 1080;
			return (charge[type][0]*minutes[0]+charge[type][1]*minutes[1]);
		}
		else if (end<=1440)
		{
			minutes[0] = 1080 - start;
			minutes[1] = 240;
			minutes[2] = end - 1320;
			return (charge[type][0]*minutes[0]+charge[type][1]*minutes[1]+charge[type][2]*minutes[2]);
		}
	}
	else if (start<1320)
	{
		if (end<=1320)
		{
			minutes[1] = end - start;
			return (charge[type][1]*minutes[1]);
		}
		else if (end<=1440)
		{
			minutes[1] = 1320 - start;
			minutes[2] = end - 1320;
			return (charge[type][1]*minutes[1]+charge[type][2]*minutes[2]);
		}
	}
	else if (start<1440)
	{
		if (end<=1440)
		{
			minutes[2] = end - start;
			return (charge[type][2]*minutes[2]);
		}
	}
	
	return 0;
}

int main()
{	
	char c;
	char number[9];
	int startHour;
	int startMinute;
	int endHour;
	int endMinute;
	int start, end;
	double total;
	int type;
	int i;

	while (1)
	{ 
		cin>>c;
		if (c=='#')
			break;
		cin>>number;
		cout<<setfill(' ');
		cout.flags(ios::right);
		cout<<setw(10)<<number;

		cin>>startHour>>startMinute;
		cin>>endHour>>endMinute;
		start = startHour*60 + startMinute;
		end = endHour*60 + endMinute;
		type = c - 'A';
		if ((start==end)||(start-end==1440))
		{
			cout<<setfill(' ');
			cout.flags(ios::right);
			cout<<setw(6)<<"600"<<setw(6)<<"240"<<setw(6)<<"600"
				<<setw(3)<<c;
			cout.flags(ios::right);
			cout.flags(ios::fixed);
			cout<<setw(8)<<setprecision(2)<<dayCost[type]<<endl;
			continue;
		}
		minutes[0] = minutes[1] = minutes[2] = 0;
		if (start<end)
		{
			total = getCost(start, end, type);
			for (i=0; i<3; i++)
			{
				cout<<setfill(' ');
				cout.flags(ios::right);
				cout<<setw(6)<<minutes[i];
			}
		}
		else
		{
			total = dayCost[type] - getCost(end, start, type);
			cout<<setfill(' ');
			cout.flags(ios::right);
			if (minutes[0]==0)
			{
				cout<<setw(6)<<"600";
			}
			else
			{
				cout<<setw(6)<<(600-minutes[0]);
			}
			if (minutes[1]==0)
			{
				cout<<setw(6)<<"240";
			}
			else
			{
				cout<<setw(6)<<(240-minutes[1]);
			}
			if (minutes[2]==0)
			{
				cout<<setw(6)<<"600";
			}
			else
			{
				cout<<setw(6)<<(600-minutes[2]);
			}  
		}  
		cout<<setfill(' ');
		cout.flags(ios::right);
		cout<<setw(3)<<c;
		cout<<setfill(' ');
		cout.flags(ios::right);
		cout.flags(ios::fixed);
		cout<<setw(8)<<setprecision(2)<<total<<endl;
	}  
	
	return 0;
}
[/cpp]
I use the If And Else arithmetic!
Beg your helps!

Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

For the sample input your code returned

Code: Select all

  183-5724     2     4     0A    0.44
while the following was expected:

Code: Select all

  183-5724     2     4     0  A    0.44

Zhls
New poster
Posts: 9
Joined: Sat Oct 16, 2004 2:14 pm

Post by Zhls »

But I realy get the Correct Answer In my Computer.
In my Computer ,the Output for the Sample Input is As:

Code: Select all

  183-5724     2     4     0  A    0.44
Otherwise I don't think it can confuse my for so long time!


But I think it may be having something with my Complier.
I'm using the Microsoft Visual C++ 6.0.
And it is said that the OJ use GNU C under the Linux.
(I get that information when I work with the Pro.147.
On this Forum, many people use "long long", but I cannot find it in my
C++ lib even in the MSDN, When I use it ,the Complier give me a error as "long follow another long error". Then I try to use _int64, and use special printf to print :
printf("%6.2lf%17I64Ld\n", amount, ways[index] );
but OJ give me a Complier Error when I send it!
)
So Can someone give me some suggestion about the Complier I must
use to satisfy the OJ?
I'm a beginner, And I love programming very much!

Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

OJ is using gcc 2.95.

VC++ 6.0 doesn't support long longs and gcc doesn't support _int64. The correct way to print long longs is either send them to cout or use printf("%ldd", long_long_variable).

Your problem is caused by old gcc weak support of iomanip. Try to replace
[cpp]cout << setw(3) << c[/cpp] by [cpp]cout << " " << c; [/cpp]
You can also remove from your code all lines like
[cpp]cout.setfill(' ');
cout.flags(ios::right);[/cpp]as they do nothing here.

Zhls
New poster
Posts: 9
Joined: Sat Oct 16, 2004 2:14 pm

Post by Zhls »

Thank you very much for your warm heart. Krzysztof Duleba!
As the hints in your first reply, I continue with my C++ program, and
This time I use the ch[2] to recieve the first alpha of the input,
and never change other places.
and I keep use line like:

Code: Select all

 cout<<setfill(' ');
 cout.flags(ios::right);
 cout<<setw(3)<<ch;
This time the OJ give me a AC!
So it seem that setw() is of no effect to characters in gcc!

Besides, I think i will explain why i use so much useless lines like:

Code: Select all

cout<<setfill(' ');
cout.flags(ios::right);
It is all because the P.E have give me so much uncertain that I must try
all the ways to get it out, although i realy know they are unless!

The end, thanks for your suggestion again!

miracle
New poster
Posts: 10
Joined: Sat Apr 16, 2005 9:40 am

Post by miracle »

Hi,my algorithm is the same as you ,and also got WA,let's help each other!
Here is my code:

//FileName : 145.cpp

//Author : Wang Bo



#include <stdio.h>

#include <iostream.h>

#include <string.h>



double rate[5][4]={0.02,0.10,0.06,0.02,

0.05,0.25,0.15,0.05,

0.13,0.53,0.33,0.13,

0.17,0.87,0.47,0.17,

0.30,1.44,0.80,0.30

};



short seg[5]={0,8,18,22,24};



int main()

{

bool flag[1440];

char des,telno[10];

int sh,sm,eh,em,time[4],i,j;

double cost;



while(1)

{

cin>>des;

if(des=='#')

break;

cin>>telno>>sh>>sm>>eh>>em;

memset(time,0,sizeof(time));

memset(flag,false,sizeof(flag));

if(eh<sh)

eh+=24;

for(i=sh*60+sm+1;i<=eh*60+em;i++)

flag[i%1440]=true;

for(i=0;i<=3;i++)

for(j=seg*60+1;j<=seg[i+1]*60;j++)

if(flag[j%1440])

time++;

cost=0;

for(i=0;i<=3;i++)

cost+=(rate[des-'A']*time);

printf(" %s%6d%6d%6d%3c%8.2lf\n",telno,time[1],time[2],time[0]+time[3],des,cost);

}

return 0;

}

miracle
New poster
Posts: 10
Joined: Sat Apr 16, 2005 9:40 am

Post by miracle »

Hi,oulongbin ,did you consider about the call which last 24 hours?
[/quote]no call may last more than 24 hours.
I've changed my code,but still WA

//FileName : 145.cpp

//Author : Wang Bo



#include <stdio.h>

#include <iostream.h>

#include <string.h>



double rate[5][4]={0.02,0.10,0.06,0.02,

0.05,0.25,0.15,0.05,

0.13,0.53,0.33,0.13,

0.17,0.87,0.47,0.17,

0.30,1.44,0.80,0.30

};



short seg[5]={0,8,18,22,24};



int main()

{

bool flag[1440];

char des,telno[10];

int sh,sm,eh,em,time[4],i,j;

double cost;



while(1)

{

cin>>des;

if(des=='#')

break;

cin>>telno>>sh>>sm>>eh>>em;

if(sh==eh && sm==em)

{

time[0]=600;

time[1]=240;

time[2]=600;

time[3]=0;

}

else

{

memset(time,0,sizeof(time));

memset(flag,false,sizeof(flag));

if(eh<sh)

eh+=24;

for(i=sh*60+sm+1;i<=eh*60+em;i++)

flag[i%1440]=true;

for(i=0;i<=3;i++)

for(j=seg*60+1;j<=seg[i+1]*60;j++)

if(flag[j%1440])

time++;

}

cost=0;

for(i=0;i<=3;i++)

cost+=(rate[des-'A']*time);

printf("%10s%6d%6d%6d%3c%8.2lf\n",telno,time[1],time[2],time[0]+time[3],des,cost);

}

return 0;

}

Jemerson
Learning poster
Posts: 59
Joined: Mon Feb 02, 2004 11:19 pm
Contact:

145 - Gondwanaland Telecom - Home Made Input To Help You

Post by Jemerson »

An extra input/output i've made to help me getting my prog. accepted (NO P.E)

input:

Code: Select all

A 183-5724 17 58 18 04
C 902-1234 00 00 23 59
C 652-8814 11 35 11 34
C 555-1904 18 00 17 59
C 902-1234 15 48 15 47
C 412-6666 21 48 21 47
E 555-1904 17 59 22 01
E 555-1904 18 00 17 59
E 555-1904 07 59 07 58
B 555-1904 01 52 02 52
D 322-5646 21 59 22 00
D 322-5646 08 00 08 01
A 399-1444 07 59 08 01
#
output:

Code: Select all

  183-5724     2     4     0  A    0.44
  902-1234   600   240   599  C  475.07
  652-8814   599   240   600  C  474.67
  555-1904   599   240   600  C  474.67
  902-1234   599   240   600  C  474.67
  412-6666   600   239   600  C  474.87
  555-1904     1   240     1  E  193.74
  555-1904   599   240   600  E 1234.56
  555-1904   600   240   599  E 1235.70
  555-1904     0     0    60  B    3.00
  322-5646     0     1     0  D    0.47
  322-5646     1     0     0  D    0.87
  399-1444     1     0     1  A    0.12
Good Luck
UFCG Brazil - Computer Science graduate student
http://acm.uva.es/problemset/usersnew.php?user=54806 ... and going up!

daveon
Experienced poster
Posts: 229
Joined: Tue Aug 31, 2004 2:41 am
Location: TORONTO, CANADA

Post by daveon »

I would also like to add that you should note the differences between times and time intervals.

IRA
Learning poster
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am

145 why WA!?

Post by IRA »

Please help me...
Thanks in advance!

Code: Select all

#include <cstdio>

double t[5][3]=	{
					{0.10,0.06,0.02},
					{0.25,0.15,0.05},
					{0.53,0.33,0.13},
					{0.87,0.47,0.17},
					{1.44,0.80,0.30}
				};


int main()
{
	char sen[1000];
	char rate;
	char num[100];
	int a,b,c,d;
	int start,end;
	int day,eve,night;
	double total;
	while(gets(sen))
	{
		if(sen[0]=='#')
			break;
		day=eve=night=0;
		sscanf(sen,"%c %s %2d %2d %2d %2d",&rate,num,&a,&b,&c,&d);
		start=a*60+b;
		end=c*60+d;

		if(start>end)
		{
			if(start>=0&&start<=480)
			{
				if(end<=480)
				{
					night=(480-start)+(end-0)+120;/////
					day=600;/////
					eve=240;/////
				}
			}
			else if(start>480&&start<=1080){
				if(end<=480)
				{
					night=(end-0)+120;//
					day=1080-start;//
					eve=240;//
				}else{
					if(end<=1080)
					{
						night=480+120;//
						day=(1080-start)+(end-480);//
						eve=240;//
					}
				}
			}else if(start>1080&&start<=1320){
				if(end<=480)
				{
					night=(end-0)+120;//
					day=0;//
					eve=1320-start;//
				}else{
					if(end<=1080)
					{
						night=120+480;//
						day=(end-480);//
						eve=1320-start;//
					}else{
						if(end<=1320)
						{
							night=120+480;//
							day=600;//
							eve=(end-1080)+(1320-start);//
						}
					}
				}
			}else{
				if(end<=480)
				{
					night=(end-0)+(2400-start);//
					day=0;//
					eve=0;//
				}else{
					if(end<=1080)
					{
						night=480+(2400-start);//
						day=(end-480);
						eve=0;
					}else{
						if(end<=1200)
						{
							night=(2400-start)+480;
							day=600;
							eve=(end-1080);
						}else{
							night=(2400-start)+480+(end-1320);//
							day=600;//
							eve=120;	//
						}
					}
				}			
			}
			total=day*t[rate-'A'][0]+eve*t[rate-'A'][1]+night*t[rate-'A'][2];
			if((int)total/1000)
				printf("  %s%6d%6d%6d  %c %.2lf\n",num,day,eve,night,rate,total);
			else if((int)total/100)
				printf("  %s%6d%6d%6d  %c  %.2lf\n",num,day,eve,night,rate,total);
			else if((int)total/10)
				printf("  %s%6d%6d%6d  %c   %.2lf\n",num,day,eve,night,rate,total);
			else 
				printf("  %s%6d%6d%6d  %c    %.2lf\n",num,day,eve,night,rate,total);
		}else if(end>start){
			if(start>=0&&start<=480)
			{
				if(end<=480)
				{
					night=end-start;
					day=0;
					eve=0;
				}else{
					if(end<=1080)
					{
						night=480-start;
						day=end-480;
						eve=0;
					}else{
						if(end<=1320)
						{
							night=480-start;
							day=600;
							eve=end-1080;							
						}else{
							night=(480-start)+(end-1320);
							day=600;
							eve=240;								
						}
					}
				}
			}
			else if(start>480&&start<=1080){
					if(end<=1080)
					{
						night=0;
						day=end-start;
						eve=0;
					}else{
						if(end<=1320)
						{
							night=0;
							day=1080-start;
							eve=end-1080;							
						}else{
							night=end-1320;
							day=1080-start;
							eve=240;								
						}
					}
			}else if(start>1080&&start<=1320){
						if(end<=1320)
						{
							night=0;
							day=0;
							eve=end-start;							
						}else{
							night=end-1320;
							day=0;
							eve=1320-start;								
						}			
			}else{
							night=end-start;
							day=0;
							eve=0;				
			}
			total=day*t[rate-'A'][0]+eve*t[rate-'A'][1]+night*t[rate-'A'][2];
			if((int)total/1000)
				printf("  %s%6d%6d%6d  %c %.2lf\n",num,day,eve,night,rate,total);
			else if((int)total/100)
				printf("  %s%6d%6d%6d  %c  %.2lf\n",num,day,eve,night,rate,total);
			else if((int)total/10)
				printf("  %s%6d%6d%6d  %c   %.2lf\n",num,day,eve,night,rate,total);
			else 
				printf("  %s%6d%6d%6d  %c    %.2lf\n",num,day,eve,night,rate,total);
		}else{

		}




	}

	return 0;
}

IRA
Learning poster
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am

Post by IRA »

Code: Select all

#include <cstdio>

double t[5][3]=	{
					{0.10,0.06,0.02},
					{0.25,0.15,0.05},
					{0.53,0.33,0.13},
					{0.87,0.47,0.17},
					{1.44,0.80,0.30}
				};


int main()
{
	char sen[1000];
	char rate;
	char num[100];
	int a,b,c,d;
	int start,end;
	int day,eve,night;
	double total;
	while(gets(sen))
	{
		if(sen[0]=='#')
			break;
		day=eve=night=0;
		sscanf(sen,"%c %s %2d %2d %2d %2d",&rate,num,&a,&b,&c,&d);
		start=a*60+b;
		end=c*60+d;

		if(start>end)
		{
			if(start>=0&&start<=480)
			{
				if(end<=480)
				{
					night=(480-start)+(end-0)+120;/////
					day=600;/////
					eve=240;/////
				}
			}
			else if(start>480&&start<=1080){
				if(end<=480)
				{
					night=(end-0)+120;//
					day=1080-start;//
					eve=240;//
				}else{
					if(end<=1080)
					{
						night=480+120;//
						day=(1080-start)+(end-480);//
						eve=240;//
					}
				}
			}else if(start>1080&&start<=1320){
				if(end<=480)
				{
					night=(end-0)+120;//
					day=0;//
					eve=1320-start;//
				}else{
					if(end<=1080)
					{
						night=120+480;//
						day=(end-480);//
						eve=1320-start;//
					}else{
						if(end<=1320)
						{
							night=120+480;//
							day=600;//
							eve=(end-1080)+(1320-start);//
						}
					}
				}
			}else{
				if(end<=480)
				{
					night=(end-0)+(1440-start);//
					day=0;//
					eve=0;//
				}else{
					if(end<=1080)
					{
						night=480+(1440-start);//
						day=(end-480);
						eve=0;
					}else{
						if(end<=1320)
						{
							night=(1440-start)+480;
							day=600;
							eve=(end-1080);
						}else{
							night=(1440-start)+480+(end-1320);//
							day=600;//
							eve=120;	//
						}
					}
				}			
			}
			total=(double)day*t[rate-'A'][0]+(double)eve*t[rate-'A'][1]+(double)night*t[rate-'A'][2];
			if((int)total/1000)
				printf("  %s%6d%6d%6d  %c %.2lf\n",num,day,eve,night,rate,total);
			else if((int)total/100)
				printf("  %s%6d%6d%6d  %c  %.2lf\n",num,day,eve,night,rate,total);
			else if((int)total/10)
				printf("  %s%6d%6d%6d  %c   %.2lf\n",num,day,eve,night,rate,total);
			else 
				printf("  %s%6d%6d%6d  %c    %.2lf\n",num,day,eve,night,rate,total);
		}else if(end>start){
			if(start>=0&&start<=480)/////////////////////////
			{
				if(end<=480)
				{
					night=end-start;
					day=0;
					eve=0;
				}else{
					if(end<=1080)
					{
						night=480-start;
						day=end-480;
						eve=0;
					}else{
						if(end<=1320)
						{
							night=480-start;
							day=600;
							eve=end-1080;							
						}else{
							night=(480-start)+(end-1320);
							day=600;
							eve=240;								
						}
					}
				}
			}
			else if(start>480&&start<=1080){
					if(end<=1080)
					{
						night=0;
						day=end-start;
						eve=0;
					}else{
						if(end<=1320)
						{
							night=0;
							day=1080-start;
							eve=end-1080;							
						}else{
							night=end-1320;
							day=1080-start;
							eve=240;								
						}
					}
			}else if(start>1080&&start<=1320){
						if(end<=1320)
						{
							night=0;
							day=0;
							eve=end-start;							
						}else{
							night=end-1320;
							day=0;
							eve=1320-start;								
						}			
			}else{
							night=end-start;
							day=0;
							eve=0;				
			}
			total=(double)day*t[rate-'A'][0]+(double)eve*t[rate-'A'][1]+(double)night*t[rate-'A'][2];
			if((int)total/1000)
				printf("  %s%6d%6d%6d  %c %.2lf\n",num,day,eve,night,rate,total);
			else if((int)total/100)
				printf("  %s%6d%6d%6d  %c  %.2lf\n",num,day,eve,night,rate,total);
			else if((int)total/10)
				printf("  %s%6d%6d%6d  %c   %.2lf\n",num,day,eve,night,rate,total);
			else 
				printf("  %s%6d%6d%6d  %c    %.2lf\n",num,day,eve,night,rate,total);
		}else{
			printf("  %s%6d%6d%6d  %c    %.2lf\n",num,day,eve,night,rate,0.0);
		}




	}

	return 0;
}

Post Reply

Return to “Volume 1 (100-199)”