Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- // #define N 3
- // don't use magic numbers
- // check the sumac, i guess the problem is there. Didn't tested
- float sumac(float[3][], int);
- void arrange(float[3][], int, int);
- int
- main(int argc, char* argv[])
- {
- int i, j;
- float x[3][3];
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
- cin >> x[i][j];
- for (j = 0; j < 3; j++)
- for (i = 0; i < 3; i++) {
- if (sumac(x, i) > sumac(x, i + 1))
- arrange(x, i, i + 1);
- }
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 3; j++)
- cout << x[i][j];
- cout << endl;
- }
- cin.ignore();
- cin.get();
- }
- float
- sumac(float x[3][3], int c)
- {
- float csum = 0;
- for (int i=0; i<3; i++)
- csum += x[i][c];
- return csum;
- }
- void
- arrange(float x[3][3], int r1, int r2)
- {
- int j, temp = 0;
- for (j=0; j<3; j++) {
- temp = x[r1][j];
- x[r1][j] = x[r2][j];
- x[r2][j] = temp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement