Syntax basics (variables, input and output, expressions and sequential statements)

Author: Attack on Siege Lion
Personal homepage: [Welcome to my homepage]
First release time: Tuesday, August 3, 2022
Subscription column: Brush questions
Personal creed: Starlight does not ask passers-by, years pay off.
If the article is wrong, welcome to correct it in the comment area.
🎉 Support me: Like👍+ Favorite ⭐️+ Comment 📝

Article directory

609. Salary

Please write a program that can read an employee’s employee number, total working hours (hours) and hourly salary this month, and output his salary slip, which includes the employee number and the employee’s monthly income.

input format

The input consists of two integers and one floating point number representing the employee number, hours worked, and hourly wage.

One line for each number.

output format

The output consists of two lines. The first line is in the format NUMBER = X, where XX is the employee number.

The format of the second line is SALARY = U$ Y, where YY is the employee’s monthly income, with two decimal places.

data range

1≤employee number≤1001≤employee number≤100,
1≤total working hours≤2001≤total working
hours≤200, 1≤hourly wage≤501≤hourly wage≤50

Input sample:

5.50

Sample output:

NUMBER = 25
SALARY = U$ 550.00

#include<iostream>
using namespace std;
int main(){
    int id;
    int time;
     double price;
     cin>>id>>time>>price;
     printf("NUMBER = %d\nSALARY = U$ %.2f",id,time*price);
}

615. Fuel consumption

Given the total distance traveled by a car (kmkm) and the amount of fuel consumed (ll), please find out how many kilometers the car can travel per 11 liters of gasoline.

input format

Input a total of two lines, the first line contains the integer XX, which represents the total distance traveled.

The second line contains the floating point number YY to one decimal place, representing the amount of oil consumed.

output format

The output format is M km/l, where MM is the calculation result with three decimal places.

data range

1≤X,Y≤1091≤X,Y≤109

Input sample:

35.0

Sample output:

14,286km/l

#include<iostream>
using namespace std;
int a;double b;
int main(){
    cin>>a>>b;
    printf("%.3lf km/l",a/b);
}

616. Distance between two points

Given two points P1P1 and P2P2, where the coordinates of P1P1 are (x1,y1)(x1,y1) and the coordinates of P2P2 are (x2,y2)(x2,y2), please calculate the distance between the two points .

distance=(x2−x1)2+(y2−y1)2−−−−−−−−−−−−−−−−−−√distance=(x2−x1)2+(y2−y1)2

input format

Input a total of two lines, each line contains two double-precision floating-point numbers xi, yixi, yi, which represent the coordinates of one of the points.

Enter values ​​with one decimal place.

output format

Print your result to four decimal places.

data range

−109≤xi,yi≤109−109≤xi,yi≤109

Input sample:

1.0 7.0
5.0 9.0

Sample output:

4.4721

#include<cstdio>
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    double a,b,c,d,e;
    cin>>a>>b>>c>>d;
    e=sqrt((c-a)*(c-a)+(d-b)*(d-b));
    printf("%.4lf",e);
    return 0;
}

653. Banknotes

In this problem, you need to read an integer value and decompose it into the sum of multiple banknotes, using multiple banknotes of each denomination, and ask to use as few banknotes as possible.

Please output the read value and the banknote list.

Possible denominations of banknotes are 100, 50, 20, 10, 5, 2, 1100, 50, 20, 10, 5, 2, 1.

input format

Enter an integer NN.

output format

Referring to the output sample, output the read value and the required number of banknotes of each denomination.

data range

0<N<10000000<N<1000000

Input sample:

Sample output:

5  note(s) of R$ 100.00 
1  note(s) of R$ 50.00 
1  note(s) of R$ 20.00 
0  note(s) of R$ 10.00 
1  note(s) of R$ 5.00 
0  R$ 2.00 note(s) 
1  R$ 1.00 note(s).

#include<iostream>
using namespace std;
int a;
int main(){
    cin>>a;
    printf("%d\n%d nota(s) de R$ 100,00\n",a,a/100);
    printf("%d nota(s) de R$ 50,00\n",(a%100)/50);
    printf("%d nota(s) de R$ 20,00\n",((a%100)%50)/20);
    printf("%d nota(s) de R$ 10,00\n",(((a%100)%50)%20)/10);
    printf("%d nota(s) de R$ 5,00\n",(((((a%100)%50)%20)%10)/5));
    printf("%d nota(s) de R$ 2,00\n",((((((a%100)%50)%20)%10)%5)/2));
    printf("%d nota(s) de R$ 1,00",(((((((a%100)%50)%20)%10)%5)%2)/1));
}

1                       Learning is like rowing against the current, if you don't advance, you will retreat

Leave a Comment

Your email address will not be published. Required fields are marked *