Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Билет 21
- #include <iostream> Задание 3
- #include <iomanip>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- const int arraySize = 100;
- int array[arraySize][arraySize];
- int summArray[arraySize] = { 0 };
- int col, row;
- cout << "Введите кол-во строк матрицы: ";
- cin >> row;
- cout << "Введите кол-во столбцов матрицы: ";
- cin >> col;
- for (int i = 0; i < row; ++i) {
- for (int j = 0; j < col; ++j) {
- cout << "Введите A[" << i + 1 << "][" << j + 1 << "] значение: ";
- cin >> array[i][j];
- }
- }
- cout << endl << "Исходная матрица: " << endl;
- for (int i = 0; i < row; ++i) {
- for (int j = 0; j < col; ++j) {
- cout << setw(5) << array[i][j];
- }
- cout << endl;
- }
- for (int i = 0; i < row; ++i) {
- for (int j = 0; j < col; ++j) {
- summArray[i] += array[i][j];
- }
- }
- cout << endl;
- for (int i = 0; i < col; ++i) {
- cout << "Сумма " << i + 1 << "столбца: " << setw(5) << summArray[i] << endl;
- }
- return 0;
- }
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- int i, c, kolvo = 0, max1 = 0;
- char ar[256];
- cout << "Введите строку: \n";
- for (i = 0; (c = getchar()) != '\n' && i <= 255; i++)
- ar[i] = c;
- for (i = 0; i != 256; i++)
- if (ar[i] == ' ')
- kolvo++;
- else if (ar[i] != ' ')
- if (kolvo > max1) {
- max1 = kolvo;
- kolvo = 0;
- }
- cout << max1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement