Home > Back-end >  Help me to look at this problem
Help me to look at this problem

Time:10-04

Subject requirements according to a certain city ordinary taxi fee standards, write a program to calculate the fare, specific standard is as follows:

Start mileage of 3 kilometers, the starting fare 10 yuan.

Super start mileage within 10 km, 2 yuan per kilometer.

The part of more than 10 kilometers above 50% of the circular extra allowance, namely 3 yuan per kilometer.

Operating process, because the road resistance and passenger requests a temporary parking, according to 2 yuan per five minutes collecting (less than five minutes is not charging),

Input format requirements:

Input in the input range is given in the line (real Numbers, the unit for km) and the waiting time (integer, the unit is minutes), separated by Spaces,

The output format requirements:

In a line of output passengers should pay the fare (unit is yuan), round result, keep to the yuan,

CodePudding user response:

Section equation

Column a equation can

CodePudding user response:

The
reference 1 floor? Victor.?? Response:
section equation
Column a equation can


I want to write a program

CodePudding user response:

If (x> 0 & amp; & x
=3)Y=10;
If (x> 3 & amp; & x<=10)
Y=10 + (x - 3) * 2;
If (x> 10)
Y=10 + 14 + (x - 10) * 3;
If (t>
=5)Y +=2 * (t/5);
Pay attention to the variable type integer and real can

CodePudding user response:

# include & lt; stdio.h>
# include & lt; Stdlib. H>

Int main ()
{
Float a, b, s;
Int c, t;
The scanf (" % f, % d ", & amp; S, & amp; T);
If (s
=3)A=10;
Else if (s> 3 & amp; & S<=10)
A=2 * s + 4;
The else
A=3 * s - 6;
If (t<5)
B=0;
The else
B=(t % 5) * 2;

C=(int) (a + b + 0.5);
Printf (" % d ", c);
return 0;
}
Why I have this problem

CodePudding user response:

# include & lt; stdio.h>
# include & lt; Stdlib. H>

Int main ()
{
Float a, b, s;
Int c, t;
The scanf (" % f, % d ", & amp; S, & amp; T);
If (s
=3)A=10;
Else if (s> 3 & amp; & S<=10)
A=2 * s + 4;
The else
A=3 * s - 6;
If (t<5)
B=0;
The else
B=(t % 5) * 2;

C=(int) (a + b + 0.5);
Printf (" % d ", c);
return 0;
}
I this when t is greater than 5 even if the wrong why ah

CodePudding user response:

B=(t % 5) * 2;

Change

B=(t/5) * 2;

CodePudding user response:

The
refer to 6th floor? Victor.?? Response:
b=(t % 5) * 2;

Change

B=(t/5) * 2;

Seems not goozyet

CodePudding user response:

Where no

For example

CodePudding user response:

Such as I enter 12.5 9 will hit 40 but the correct answer is 34

CodePudding user response:

 
# include & lt; stdio.h>
# include & lt; Stdlib. H>
Int main (int arg c, char * * argv) {
Int pay=10, length, waittime;
The scanf (" % d % d ", & amp; Length, & amp; Waittime);
While ((waittime -=5) & gt;=0) pay +=2;
If (length<{
=3)Printf (" \ n pay: % d ", pay);
return 0;
}
Length -=3;
If (length<=10) {
Pay +=length * 2;
Printf (" \ n pay: % d ", pay);
return 0;
}
Pay +=20;
Length -=10;
Pay +=length * 3;
Printf (" \ n pay: % d ", pay);
return 0;
}

CodePudding user response:

You have to do is define b over the int

CodePudding user response:

# 4, "a=2 * s + 4" the logic of this statement is not in conformity with the "super start mileage within 10 km, 2 yuan per kilometer;" Description,
Should be "a=2 * (s - 3)".
  • Related