Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######################################
- Задача на расчет расстояния м/у 2 точками в X, Y, Z
- #include <cmath>
- #include <iostream>
- #include <iomanip>
- using std::cout;
- using std::cin;
- using std::endl;
- int main()
- {
- cout << "Please enter A (x1,y1,z1) = " << endl;
- double x1{};
- cin >> x1;
- double y1{};
- cin >> y1;
- double z1{};
- cin >> z1;
- cout << "Please enter B (x2,y2,z2) = " << endl;
- double x2{};
- cin >> x2;
- double y2{};
- cin >> y2;
- double z2{};
- cin >> z2;
- double R;
- R = sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2) + pow((z2 - z1), 2));
- cout << std::setprecision(10) << "The distance between A (x1,y1,z1) and B (x2,y2,z2) = " << R << endl;
- return 0;
- }
- #############################
- Задача на на нахождение P и S произвольного треугольника
- #include <cmath>
- #include <iostream>
- #include <iomanip>
- using std::cout;
- using std::cin;
- using std::endl;
- int main()
- {
- cout << "Please enter A (x1,y1) = " << endl;
- double x1{};
- cin >> x1;
- double y1{};
- cin >> y1;
- cout << "Please enter B (x2,y2) = " << endl;
- double x2{};
- cin >> x2;
- double y2{};
- cin >> y2;
- cout << "Please enter C (x3,y3) = " << endl;
- double x3{};
- cin >> x3;
- double y3{};
- cin >> y3;
- double N;
- N = sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));
- double M;
- M = sqrt(pow((x3 - x2), 2) + pow((y3 - y2), 2));
- double K;
- K = sqrt(pow((x3 - x1), 2) + pow((y3 - y1), 2));
- double P;
- P = N + M + K;
- double L;
- L = P*0.5;
- double S;
- S = sqrt(L*(L - N)*(L - M)*(L - K));
- cout << std::setprecision(10) << "AB = " << N << endl;
- cout << std::setprecision(10) << "BC = " << M << endl;
- cout << std::setprecision(10) << "AC = " << K << endl;
- cout << std::setprecision(10) << "P = " << P << endl;
- cout << std::setprecision(10) << "S = " << S << endl;
- return 0;
- }
- #########################################
- Задача на нахождение суммы четырехзначного числа
- #include <cmath>
- #include <iostream>
- using std::cout;
- using std::cin;
- using std::endl;
- int main()
- {
- cout << "Please enter number = " << endl;
- int N, x1, x2, x3, x4 {};
- cin >> N;
- x4 = N % 10;
- x3 = N / 10 % 10;
- x2 = N / 100 % 10;
- x1 = N / 1000;
- int S;
- S = x1 + x2 + x3 + x4;
- cout << "S = " << S << endl;
- return 0;
- }
- #################################
- Задача на нахождение суммы трехзначного числа:
- #include <cmath>
- #include <iostream>
- using std::cout;
- using std::cin;
- using std::endl;
- int main()
- {
- cout << "Please enter number = " << endl;
- int N, x1, x2, x3 {};
- cin >> N;
- x3 = N % 10;
- x2 = N / 10 % 10;
- x1 = N / 100;
- int S;
- S = x1 + x2 + x3;
- cout << "S = " << S << endl;
- return 0;
- }
- ###################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement