Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void row(int a, int b, int n, int array[9][9])
- {
- int temp[9];
- int i;
- for(i = 0; i < n; i++)
- {
- temp[i] = array[a][i];
- array[a][i] = array[b][i];
- array[b][i] = temp[i];
- }
- }
- void col(int a, int b, int n, int array[9][9])
- {
- int temp[9];
- int i;
- for(i = 0; i < n; i++)
- {
- temp[i] = array[i][a];
- array[i][a] = array[i][b];
- array[i][b] = temp[i];
- }
- }
- void inc(int array[9][9], int n)
- {
- int i, j;
- for(i = 0; i < n; i++)
- {
- for(j = 0; j < n; j++)
- {
- array[i][j] = array[i][j] + 1;
- if(array[i][j] == 10)
- {
- array[i][j] = 0;
- }
- }
- }
- }
- void dec(int array[9][9], int n)
- {
- int i, j;
- for(i = 0; i < n; i++)
- {
- for(j = 0; j < n; j++)
- {
- array[i][j] = array[i][j] - 1;
- if(array[i][j] == -1)
- {
- array[i][j] = 9;
- }
- }
- }
- }
- int main()
- {
- int t;
- int n, m;
- int i, j;
- int array[9][9];
- char func[51];
- int a, b;
- scanf("%d", &t);
- for(i = 0; i < t; i++)
- {
- scanf("%d", &n);
- for(i = 0; i < n; i++)
- {
- for(j = 0; j < n; j++)
- {
- scanf("%d", &array[i][j]);
- }
- }
- scanf("%d", &m);
- for(i = 0; i < m; i++)
- {
- scanf("%s", func);
- if(strcmp (func, "row"))
- {
- scanf("%d%d", &a, &b);
- row(a, b, n, array);
- }
- if(strcmp (func, "col"))
- {
- scanf("%d%d", &a, &b);
- col(a, b, n, array);
- }
- if(strcmp (func, "inc"))
- {
- inc(array, n);
- }
- if(strcmp (func, "dec"))
- {
- dec(array, n);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement