#include <iostream>
#include <vector>
using namespace std;
void modify(vector<vector<int>> &v){
const int N = v.size(), M = v.front().size();
for(int i = 0; i < N; i++)
for(int j = 0; j < M; j++)
v[i][j] -= (i + 1);
}
signed main() {
int n, m;
cin >> n >> m;
vector<vector<int>> a(n, vector<int> (m, 0));
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> a[i][j];
modify(a);
for(int i = 0; i < n; i++){
cout << a[i][j] << " ";
cout << "\n";
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <vector>
using namespace std;
void modify(vector<vector<int>> &v){
const int N = v.size(), M = v.front().size();
for(int i = 0; i < N; i++)
for(int j = 0; j < M; j++)
v[i][j] -= (i + 1);
}
signed main() {
int n, m;
cin >> n >> m;
vector<vector<int>> a(n, vector<int> (m, 0));
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> a[i][j];
modify(a);
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++)
cout << a[i][j] << " ";
cout << "\n";
}
}