Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <windows.h>
- #include <iomanip>
- #include <cstring>
- #include <conio.h>
- /*
- - 1) Написать функцию которая выводит приветственное сообщение в консоль
- - 2) Сделать возможность ввода имени перед вводом всех чисел, а после вывода результатов расчёта, попрощаться с пользователем, то есть вывести: Имя, пока, друг
- - 3) Создать матрицу размером nxm, найти максимальный элемент в каждой строке и вывести на экран
- - 4) Создать два вектора, и прибавить к первому вектору второй вектор
- - 5) Написать функцию которая считает сумму трёх чисел и возвращает результат
- */
- int MATRIX_SIZE = 4;
- using namespace std;
- // void <- ничего не возвращает
- float searchMax(float a, float b) {
- if (a > b) {
- return a;
- }
- return b;
- }
- void checkMax(float a, float b) {
- if (a > b) {
- cout << "a > b";
- } else {
- cout << "b > a";
- }
- }
- void setRussian() {
- setlocale(0, "");
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- }
- int main() {
- setRussian();
- float j = 9.3133, f = 7236.37627;
- searchMax(j, f);
- //
- /*
- 0 = Black 8 = Gray
- 1 = Blue 9 = Light Blue
- 2 = Green A = Light Green
- 3 = Aqua B = Light Aqua
- 4 = Red C = Light Red
- 5 = Purple D = Light Purple
- 6 = Yellow E = Light Yellow
- 7 = White F = Bright White
- */
- /*
- char row[80];
- cout << "Ваше имя: ";
- cin.getline(row, 80);
- cout << "Вы ввели: " << row << endl;
- */
- //cin.get();
- //getchar();
- /*
- string row; // ''
- cout << "Ваше имя: ";
- getline(cin, row);
- cout << "Вы ввели: " << row << endl;
- */
- //0 1 2 3
- //8 5 4 3
- //8 3 2 1
- //8 4 3 1
- int **matrix = new int*[MATRIX_SIZE];
- for (int k = 0; k < MATRIX_SIZE; k++) {
- matrix[k] = new int[MATRIX_SIZE];
- }
- for (int k = 0; k < MATRIX_SIZE; k++) {
- for (int j = 0; j < MATRIX_SIZE; j++) {
- //cout << "Элемент массива " << k << "-" << j << ": ";
- //cin >> matrix[k][j];
- matrix[k][j] = (k + j);
- }
- }
- for (int k = 0; k < MATRIX_SIZE; k++) {
- int summary = 0;
- for (int j = 0; j < MATRIX_SIZE; j++) {
- cout << setw(4) << matrix[k][j] << " ";
- summary += matrix[k][j];
- }
- cout << setw(20) << "Сумма элементов = " << summary << endl;
- }
- //0 1 2 3
- /*
- int *myVector = new int[MATRIX_SIZE];
- for (int k = 0; k < MATRIX_SIZE; k++) {
- myVector[k] = k;
- }
- for (int k = 0; k < MATRIX_SIZE; k++) {
- cout << myVector[k];
- }
- */
- //SetConsoleCP(1251);
- //SetConsoleOutputCP(1251);
- //system("chcp 1251");
- //int a = 9, b = 7;
- //double c = 9.538487387387;
- //float d = .9; // 0.9
- //cout.precision(3);
- //cout << "c = " << setprecision(3) << c << endl;
- //cout << "c = " << c << endl;
- //cout.width(20);
- //cout << "Какой-то текст" << setw(5) << d << "|" << setw(10) << a << endl;
- //cout << "Какой-то текст" << d << "|" << a << "|" << endl;
- //cout.setf(ios);
- //cout << "Какой-то текст" << setw(20) << d << "|" << a << "|" << endl;
- // cout << "Переменная a = " << a << "; А переменная b = " << b << endl;
- //printf("Переменная a = %d\nА переменная b = %d", a, b); // %s - string, %d - digit %f - float %lf - long float %c - char
- //printf("Переменная a перед изменением = %5.3lf", c); // %общее.после запятой+тип
- //scanf("%d", &a);
- //printf("Переменная a после изменения = %d", a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment