- Data types, variables and constants
- Ввод с клавиатуры и вывод данных на экран
- Арифметические операции и комбинированные операторы
- Операторы выбора if и else в С
- The switch statement in C ++
- The for loop in C++
- Циклы while, do while, nested loops
- Two-dimensional arrays C ++
- Arrays in C++
- Functions in C++
- Pointers C ++
- A pointer to a pointer to C ++
- Classes in C ++
Additional collection of problems with solutions
This page contains all of the tasks on the topics lessons, posted on our website. К каждой задаче прилагается наш вариант решения. Постарайтесь всё же решать их самостоятельно и только потом сравнивать наш исходный код со своим. “Хочешь научиться программировать – программируй”!
Больше практических заданий с решениями найдёте here.
Рекомендуем посетить Сайт для юных программистов – где вы найдете уроки по различным языкам программирования (в том числе для детей), 3D-моделированию, Linux и др.
Create a program for calculating the specified value
Y=2f(x)(asinx+of^-(x+3)), where x={-3from
Z^2
FROM>0
FROM<=0
You mixed up the topics.
You have a topic Two-dimensional arrays go before arrays
8. Two-dimensional arrays C ++
9. Arrays in C++
correct, it's a complete creep, what to first learn a two-dimensional array, and then you tell, WHAT IS AN ARRAY
Compose a program using two-dimensional dynamic arrays to solve the problem according to the variant of an individual task
Perform a cyclic shift of the elements of a square matrix of dimension × N to the right by k elements in this way: elements of the 1st row are shifted to the last column from top to bottom, out of him – last line from right to left, from her – in the first column from bottom to top, out of him – to the first line; for other elements – likewise.
Write a program, which outputs the value of the expression with respect to three natural variables a, b, c in full
a(b+c)
Sample Input:
3 4 5
Sample Output:
3(4+5)=27
#include
using namespace std;
int main()
{
int a(3), b(4), c(5);
cin>>a>>b>>c;
cout<<"3(4+5)=27";
return 0;
}
#include
using namespace std;
int main()
{
setlocale (LC_ALL, “Russian”);
int a, b, c, sum;
cout << "Введите число a" <> a;
cout << "Введит число b" <> b;
cout << "Введите число c" <> c;
sum = a * (b + c);
cout << a << " * (" << b << " + " << c << ") = " << sum << endl;
return 0;
}
#include
#include
double f(double x) {
// Define the function f(x) here
return /* the value of f(x) */;
}
int main() {
double z;
std::cout <> from;
double x, Y;
if (from > 0) {
x = -3 * pow(from, 2);
y = 2 * f(x) * (asin(x) + (double)exp(-x – 3));
std::cout < 0, x = ” << x << " and y = " << Y << std::endl;
} else {
x = -3 * pow(from, 2);
y = 2 * f(x) * (asin(x) + (double)exp(-x – 3));
std::cout << "For Z <= 0, x = " << x << " and y = " << Y << std::endl;
}
return 0;
}
Create function module (Modular programming in C++) with processing algorithms
one-dimensional arrays for int types, float (using the function overload mechanism). It is all
necessary data for functions should be passed to them as parameters.
The use of global variables and I/O operations in functions is not
allowed.
—————-
§ filling with random values;
§ calculation of the sum, products of array elements in a given index range
using predicate functions;
§ insertion and deletion of array element/elements based on shift algorithms;
§ array sorting, at least three quadratic complexity class algorithms;
§ linear search algorithm in the implementation of tasks: search for maximum and minimum
elements;
§ binary search algorithm for a given key in an array;
§ counting the number of elements with a specified characteristic (positive,
negative, zero, multiples of t), using predicate functions
§ input/output of array elements, file input/output of array elements
file I/O, use text and binary files.
To solve this problem, you can use the following Python code:
python
def f(x):
return 2 * (math.sin(x) + math.e ** (-x - 3))
def U(z):
if z > 0:
x = -3 * z
elif z <= 0:
x = -3 * z ** 2
return f(x)
// Welcome to the fucking calculator!
// Update! Version 1.1 ( 27.02.2023 20:15)
//~Added ” Answer “.
//Update! Version 1.2 ( 27.01.2023 20:48 )
//~Instruction added(in English!).
//~Copyrights added.
//Update! Version 1.3 (27.02.2023 21.49)
//Version 1.3 (27.02.2023 21.49)
//~Added frame with instructions
//~Added calculation of square and cubic powers
//~Copyrights removed.
//global update!!! Version 1.4 (27.02.2023 22.52)
//~Added display of calculator actions.
//~Phrase ” Answer ” removed.
//~Code is smaller, because of which the compiler needs less processing time.
//~The exponentiation system has been redesigned. Now you can raise numbers to any degree. (read the instructions)
//Update! Version 1.5 (28.02.2023 0.42)
//~Added square root calculation.
//~Added calculation of the Pythagorean Theorem.
//~Thread altered.
//Update! Version 1.5.1 (28.02.2023 19:50)
//~Rewritten code(replacing if and else on a switch)
//~”Answer” returned under the decision line.
//Update! Version 1.6 ( in developing )
//Ideas:
//~Adding a system of variables for certain tasks
//~Translating the code into the application ( i fucking know, how to do it, to help!!! )
//~Introduction of such formulas, how:
// 1) Discriminator
// 2) Perimeter, figure area
#include
#include
using namespace std;
int main()
{
cout << " ___________________________________________________________" << endl;
cout << "|SchwarzeCalculator |" << endl;
cout << "|Instruction: |" << endl;
cout << "|To use the calculator, enter 3 digits separated by a space.|" << endl;
cout << "|Example: |" << endl;
cout << "|5 3 2 |" << endl;
cout << "|5 – the first number. |" << endl;
cout << "|3 – the second number. |" << endl;
cout << "|2 – action code. |" << endl;
cout << "|Action codes: |" << endl;
cout << "|1 – addition. |" << endl;
cout << "|2 – subtraction. |" << endl;
cout << "|3 – multiplication. |" << endl;
cout << "|4 – division. |" << endl;
cout << "|5 – exponentiation (first number – base of degree, second |" << endl;
cout << "|number – exponent |" << endl;
cout << "|6 – square root |" << endl;
cout << "|7 – Pyphagorean theorem ( both numbers – cathets |" << endl;
cout << "|8 – Pyphagorean theorem ( first number – hypitenuse, second|" << endl;
cout << "| number – cathetus |" << endl;
cout << "|___________________________________________________________|" << endl;
cout << "Enter the details below :" <> a;
cin >> b;
cin >> from;
switch (from) {
case 1:
cout << a << "+" << b << "=" << a + b << endl;
break;
case 2:
cout << a << "-" << b << "=" << a – b << endl;
break;
case 3:
cout << a << "*" << b << "=" << a * b << endl;
break;
case 4:
cout << a << "/" << b << "=" << a / b << endl;
break;
case 5:
cout << a << "^" << b << "=" << pow(a, b) << endl;
break;
case 6:
cout << "sqrt" << a << "=" << sqrt(a) << endl;
break;
case 7:
cout << a << "^2" << "+" << b << "^2" << "=" << sqrt(pow(a, 2) + pow(b, 2)) << "^2" << endl;
break;
case 8:
cout << a << "^2" << "-" << b << "^2" << "=" << sqrt(pow(a, 2) – pow(b, 2)) << "^2" << endl;
break;
}
cout << "—————————————" << endl;
cout << "Answer:";
switch (from) {
case 1:
cout << a + b << endl;
break;
case 2:
cout << a – b << endl;
break;
case 3:
cout << a * b << endl;
break;
case 4:
cout << a / b << endl;
break;
case 5:
cout << pow(a, b) << endl;
break;
case 6:
cout << sqrt(a) << endl;
break;
case 7:
cout << sqrt(pow(a, 2) + pow(b, 2)) << "^2" << endl;
break;
case 8:
cout << sqrt(pow(a, 2) – pow(b, 2)) << "^2" << endl;
break;
}
cout << " " << endl;
cout << "ver. 1.5.1" << endl;
cout << "Code by Schwarze Kydelyok" << endl;
cout << "Compiler program – MSVS 2022";
cout << " " << endl;
return 0;
}
iostream and cmath))))