Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- int main()
- {
- using namespace std;
- double mas[10][10];
- int k;
- double sum = 0;
- cout << "Enter k: " << endl;
- cin >> k;
- cout << "Enter mas: " << endl;
- for (int i=0; i<10; i++)
- for (int j = 0; j < 10; j++)
- {
- mas[j][i]=i+1;
- }
- for (int i = 0; i < 10; i++)
- {
- cout << endl;
- for (int j = 0; j < 10; j++)
- {
- cout << mas[i][j];
- }
- }
- if (k >= 0)
- {
- for (int i = 0; i < 10 - k; i++)
- {
- sum += mas[i][i + k];
- }
- }
- else
- {
- for (int j = abs(k); j < 10; j++)
- {
- sum += mas[j][j+k];
- }
- }
- cout << "Your result: " << sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement