Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int num[5000], smt[4], i, stri, h, l, nl, nh;
- int main()
- {
- cin >> l >> h;
- cin >> nl >> nh;
- stri = 1;
- for (i = 1; i <= l*h; i++)
- {
- num[i - 1] = rand() % 10;
- cout << num[i - 1] << setw(1);
- stri++;
- if (stri > l)
- {
- cout << endl;
- stri = 1;
- }
- }
- if (nh < h && nl <l)
- smt[1] = num[(nh - 1)*l + nl - 1];
- else
- {
- nh = h;
- nl = l;
- smt[1] = num[(nh - 2)*l + nl - 2];
- }
- if (nh < h && nl <l)
- smt[2] = num[(nh - 1)*l + nl];
- else smt[2] = num[(nh - 2)*l + nl - 1];
- if (nh < h && nl <l)
- smt[3] = num[nh*l + nl - 1];
- else
- smt[3] = num[(nh - 1)*l + nl - 2];
- if (nh < h && nl <l)
- smt[4] = num[nh*l + nl];
- else smt[4] = num[(nh-1)*l + nl - 1];
- cout << endl << endl;
- cout << smt[1] << setw(1) << smt[2] << endl << smt[3] << setw(1) << smt[4] << endl << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement