Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio> // ivedimas
- using namespace std;
- int main()
- {
- freopen("duom.txt", "r", stdin); // ivedimas
- int n, m[31][51], k;
- cin >> n >> k; // ivedimas
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<k; j++) cin >> m[i][j]; // ivedimas
- }
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<k; j++)
- {
- if(j==0) cout << (m[i][j]+m[i][j+1])/2 << " ";
- else if(j==k-1) cout << (m[i][j]+m[i][j-1])/2 << " ";
- else cout << (m[i][j-1]+m[i][j+1]+m[i][j])/3 << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement