Home > Back-end >  Asked bosses have a ha, help to solve a ha pintia C language
Asked bosses have a ha, help to solve a ha pintia C language

Time:10-26

Bosses, I do not know can you help me have a look at why the problem on pintia
A.c: behold: warning: ignoring the return value of the scanf, declared with the attribute warn_unused_result [- Wunused - the result]
Lf the scanf (" % % d ", & amp; S, & amp; t);
^ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
This fault, by the way could you tell me how the correct
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:
Input in the input range is given in the line (unit for km, accurate to 1 decimal places) and the waiting time (integer, the unit is minutes), separated by Spaces,
The output format:
In a line of output passengers should pay the fare (unit is yuan), round result, keep to the yuan,
Input the sample 1:
2.6 2
The output sample 1:
10
Enter the sample 2:
5.1 4
The output sample 2:
14
Enter the sample 3:
12.5 9
# include & lt; stdio.h>
# include & lt; Stdlib. H>

Int main ()
{
Double s=0, m=0;
Int t=0;
Lf the scanf (" % % d ", & amp; S, & amp; t);
If (s
=3)M=10;
If (s> 3& & S<=10)
M=10 + (s - 3) * 2;
If (s> 10)
M=10 + 7 * 2 + (s - 10) * 3;
If (t
=5){
M=m.
}
The else
{
If (t> 5)
{
M +=t/5 * 2;
}
}
Printf (" % 0 f ", m);
return 0;
}
The above is my code

CodePudding user response:

Platform that should not ignore the scanf return values, so issued a warning, but the program can run, try to declare a variable, such as int x; X=the scanf (...

CodePudding user response:

The
Lf the scanf (" % % d ", & amp; S, & amp; t);
Change
Lf the if (the scanf (" % % d ", & amp; S, & amp; T)!=2) return 1;
Have a try
  • Related