Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdlib.h>
  3. #include <random>
  4. #include "Pole2D.h"
  5. #include "iostream"
  6.  
  7.  
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10. Pole2D pole(3, 4);
  11. int *radek;
  12. const int MY_MAX = 100; // RAND_MAX
  13.  
  14. // init
  15. pole.SetValue(15, 0, 0);
  16. pole.SetValue(10, 1, 1);
  17. radek = pole[2];
  18. radek[3] = 16;
  19. // tisk
  20. for (int i = 0; i < pole.PocetRadku(); i++)
  21. {
  22. for (int j = 0; j < pole.PocetSloupcu(); j++)
  23. printf("%d;", pole.GetValue(i, j));
  24. printf("\n");
  25. }
  26.  
  27. for (int i = 0; i < pole.PocetRadku(); i++)
  28. {
  29. radek = pole[i];
  30. for (int j = 0; j < pole.PocetSloupcu(); j++)
  31. printf("%d;", pole.GetValue(i, j));
  32. printf("\n");
  33. }
  34.  
  35.  
  36. // index of
  37. int x, y = 0, m_poz, n_poz;
  38. char v = 'y';
  39. while (v == 'y'){
  40.  
  41. cout << "Zadej hledanou hodnotu:";
  42. cin >> x;
  43. try {
  44. y = 0;
  45. pole.IndexOf(x, &m_poz, &n_poz);
  46. }
  47. catch (string *caught) {
  48. cout << "Hledany prvek neexistuje!" << endl;
  49. y = 1;
  50. }
  51. if (y == 0)
  52. cout << "Hledany prvek " << x << " je na pozici [" << m_poz << " " << n_poz << "]. (Pocitano od pozice[0 0])" << endl;
  53.  
  54. cout << "Hledat novy prvek [y/n]:";
  55. cin >> v;
  56. }
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement