Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- #include <iostream>
- #include <string>
- using namespace std;
- void change() {
- int n, max = -10000, index, third, k, m;
- cout << "Enter the size of array:";
- cin >> n;
- int A[n][n];
- for (int i = 0;i < n; i++) {
- for (int j = 0;j < n; j++) {
- cin >> A[i][j] ;
- if (A[i][j] > max ) {
- max = A[i][j];
- index = j;
- }
- if (j == n - 1) {
- third = A[i][i];
- A[i][i] = max;
- A[i][index] = third;
- max = -10000;
- }
- }
- }
- //cout << i;
- for (m = 0;m < n; m++) {
- for (int l = 0;l < n; l++) {
- cout << A[m][l] << " \t ";
- }
- cout << endl;
- }
- }
- int main()
- {
- change();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement