Bob103

максимум на обратный

Dec 11th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int **creat(int &n, int &m)
  4. {
  5. cout << "n="; cin >> n; cout << "m="; cin >> m;
  6. int **mas = new int*[n];
  7. for (int i = 0; i < n; ++i)
  8. mas[i] = new int[m];
  9. for (int i = 0; i < n; ++i)
  10. for (int j = 0; j < m; ++j)
  11. {
  12. cout << "mas[" << i << "][" << j << "]="; cin >> mas[i][j];
  13. }
  14. return mas;
  15. }
  16. int main()
  17. {
  18. int n, m;
  19. cout << "n="; cin >> n; cout << "m="; cin >> m;
  20. int **a = creat(n, m);
  21. int max = a[0][0];
  22. for (int i = 0; i < n; ++i)
  23. for (int j = 0; j < m; ++j)
  24. if (a[i][j]>max)
  25. max = a[i][j];
  26. max *= -1;
  27. cout << "max=" << max<<endl;
  28. for (int i = 0; i < n; ++i)
  29. delete[]a[i];
  30. delete[]a;
  31. system("pause");
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment