djelad1

Untitled

Nov 30th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. int rows = 0, cols = 0, arr[SIZE3][SIZE3] = { 0 }, i = 0, j = 0;
  2. int max1 = 0, max2 = 0, max3 = 0, max4 = 0;
  3. cout << " please enter the numbers of rows (between1-10) : ";
  4. cin >> rows;
  5. while (rows > 10 || rows < 1)
  6. {
  7. cout << "Value should be between 1-10, please try again : ";
  8. cin >> rows;
  9. }
  10. cout << " please enter the numbers of cols (between1-10) : ";
  11. cin >> cols;
  12. while (cols > 10 || cols < 1)
  13. {
  14. cout << "Value should be between 1-10, please try again : ";
  15. cin >> cols;
  16. }
  17. cout << "enter " << rows*cols << " numbers please : ";
  18. for (i = 0; i < rows; i++)
  19. {
  20. for (j = 0; j < cols; j++)
  21. {
  22. cin >> arr[i][j];
  23. }
  24. }
  25. for (i = 0; i < rows; i++)
  26. {
  27. for (j = 0; j < cols; j++)
  28. {
  29. cout << arr[i][j] << " ";
  30. }
  31. cout << endl;
  32. }
  33. max1 = arr[0][0];
  34. for (i = 0, j = 1; j < cols; j++)
  35. {
  36. if (arr[i][j] > max1)
  37. max1 = arr[i][j];
  38. }
  39. max2 = arr[rows - 1][0];
  40. for (i = rows - 1, j = 0; j < cols; j++)
  41. {
  42. if (arr[i][j] > max1)
  43. max1 = arr[i][j];
  44. }
  45. max3 = arr[0][cols - 1];
  46. for (i = 0, j = cols - 1; i < rows; i++)
  47. {
  48. if (arr[i][j] > max1)
  49. max1 = arr[i][j];
  50. }
  51. max4 = arr[0][0];
  52. for (i = 0, j = 0; i < rows; i++)
  53. {
  54. if (arr[i][j] > max1)
  55. max1 = arr[i][j];
  56. }
  57.  
  58. cout << "the higher number on the fram is " << max1 << endl;
  59. break;
  60. system("pause");
  61. system("cls");
Advertisement
Add Comment
Please, Sign In to add comment