Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication25.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <iomanip>
- #include "stdio.h"
- #include <clocale>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(LC_ALL, "rus");
- int n, m;
- float temp;
- cout << "Введите размер матрицы:";
- cin >> n >> m;
- cout << endl;
- float **a = new float*[n];
- for (int i = 0; i < n; i++)
- a[i] = new float[m];
- cout << "Введите элементы матрицы:" << endl;
- for (int i = 0; i < n; i++){
- for (int j = 0; j < m; j++)
- cin >> a[i][j];
- }
- cout << endl;
- if (n % 2 == 0){
- for (int i = 0; i < (n / 2); i++){
- for (int j = 0; j < m; j++){
- temp = a[i][j];
- a[i][j] = a[n - 1 - i][j];
- a[n - 1 - i][j] = temp;
- }
- }
- }
- else{
- for (int i = 0; i <= (n / 2); i++){
- for (int j = 0; j < m; j++){
- temp = a[i][j];
- a[i][j] = a[n - 1 - i][j];
- a[n - 1 - i][j] = temp;
- }
- }
- }
- for (int i = 0; i < n; i++){
- for (int j = 0; j < m; j++){
- cout << a[i][j]<<" ";
- }
- cout << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement