Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int maxValue = 0;
- int rows,cols;
- int currentNum = 0;
- int biggestNumSpace = 0;
- int currentSpace = 0;
- int tempBigNum = 0;
- cout << "Please enter number of rows -->";
- cin >> rows;
- while (rows > 10 || rows < 1)
- {
- cout << "ERROR: input between 1 and 10 -->";
- cin >> rows;
- }
- cout << "Please enter number of cols -->";
- cin >> cols;
- while (cols > 10 || cols < 1)
- {
- cout << "ERROR: input between 1 and 10 -->";
- cin>> cols;
- }
- int arr[rows][cols];
- cout << "Please enter " << rows*cols << "Numbers :";
- for(int i = 0; i < rows; i++)
- {
- for(int j = 0; j < cols; j++)
- {
- cin >> arr[i][j];
- }
- }
- maxValue = arr[0][0];
- currentSpace = 0;
- cout << "The matrix is: \n";
- for(int i = 0; i < rows; i++)
- {
- for(int j = 0; j < cols; j++)
- {
- if(arr[i][j] > maxValue)
- {
- maxValue = arr[i][j];
- }
- cout << " " << arr[i][j];
- tempBigNum = maxValue;
- while(tempBigNum > 0)
- {
- tempBigNum = tempBigNum / 10;
- biggestNumSpace++;
- }
- currentNum = arr[i][j];
- while(currentNum > 0)
- {
- currentNum = currentNum / 10;
- currentSpace++;
- }
- for(int i = 0; i < (biggestNumSpace - currentSpace) + 1; i++)
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- cout << "And the biggest number value is " << maxValue << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement