Advertisement
Leon3226

Untitled

Sep 30th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int num[5000], smt[4], i, stri, h, l, nl, nh;
  5. int main()
  6. {
  7. cin >> l >> h;
  8. cin >> nl >> nh;
  9. stri = 1;
  10. for (i = 1; i <= l*h; i++)
  11. {
  12. num[i - 1] = rand() % 10;
  13. cout << num[i - 1] << setw(1);
  14. stri++;
  15. if (stri > l)
  16. {
  17. cout << endl;
  18. stri = 1;
  19. }
  20. }
  21. if (nh < h && nl <l)
  22. smt[1] = num[(nh - 1)*l + nl - 1];
  23. else
  24. {
  25. nh = h;
  26. nl = l;
  27. smt[1] = num[(nh - 2)*l + nl - 2];
  28. }
  29. if (nh < h && nl <l)
  30. smt[2] = num[(nh - 1)*l + nl];
  31. else smt[2] = num[(nh - 2)*l + nl - 1];
  32. if (nh < h && nl <l)
  33. smt[3] = num[nh*l + nl - 1];
  34. else
  35. smt[3] = num[(nh - 1)*l + nl - 2];
  36. if (nh < h && nl <l)
  37. smt[4] = num[nh*l + nl];
  38. else smt[4] = num[(nh-1)*l + nl - 1];
  39. cout << endl << endl;
  40.  
  41. cout << smt[1] << setw(1) << smt[2] << endl << smt[3] << setw(1) << smt[4] << endl << endl;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement