Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <conio.h>
  5. #include <iostream>
  6. #include <iostream>
  7. #include <windows.h>
  8.  
  9. #include <algorithm>
  10. using namespace std;
  11.  
  12. float maxtop(float* A) {
  13. float max = 0;
  14. for (int j = 0; j < 4; j++) {
  15. if (A[j] > max) {
  16. max = A[j];
  17. }
  18. }
  19. return max;
  20. }
  21.  
  22. float* maxsort(float* A) {
  23. std::sort(A, A + 3);
  24. return A;
  25. }
  26.  
  27. int main()
  28. {
  29. system("chcp 1251");
  30. system("cls");
  31. float A[3][4] = {},
  32. B[3] = {},
  33. C[3] = {},
  34. D[4][3] = {},
  35. E[3][4];
  36.  
  37. for (int i = 0; i < 3; i++) {
  38. for (int j = 0; j < 4; j++) {
  39. cout << "Введите A[" << i + 1 << "][" << j + 1 << "]" << endl;
  40. cin >> A[i][j];
  41. }
  42. }
  43.  
  44. cout << "Исходная матрица:" << endl;
  45. for (int i = 0; i < 3; i++) {
  46. for (int j = 0; j < 4; j++) {
  47. cout << A[i][j] << " ";
  48. }
  49. cout << endl;
  50. }
  51.  
  52. for (int i = 0; i < 3; i++) {
  53. B[i] = maxtop(A[i]);
  54. cout << "Максимальный элемент в строке №" << i + 1 << " это: " << B[i] << endl;
  55. }
  56.  
  57. for (int j = 0; j < 4; j++) {
  58. for (int i = 0; i < 3; i++) {
  59. D[j][i] = A[i][j];
  60. }
  61. float* C = maxsort(D[j]);
  62. for (int i = 0; i < 3; i++) {
  63. E[j][i] = C[i];
  64. }
  65. cout << "Ряд №" << j + 1 << " по позрастанию: " << C[0] << " " << C[1] << " " << C[2] << " " << endl;
  66. }
  67.  
  68. cout << "Обработанная матрица:" << endl;
  69. for (int i = 0; i < 3; i++) {
  70. for (int j = 0; j < 4; j++) {
  71. cout << E[j][i] << " ";
  72. }
  73. cout << endl;
  74. }
  75. int k;
  76. cin >> k;
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement