Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdlib.h>
- #include <random>
- #include "Pole2D.h"
- #include "iostream"
- int _tmain(int argc, _TCHAR* argv[])
- {
- Pole2D pole(3, 4);
- int *radek;
- const int MY_MAX = 100; // RAND_MAX
- // init
- pole.SetValue(15, 0, 0);
- pole.SetValue(10, 1, 1);
- radek = pole[2];
- radek[3] = 16;
- // tisk
- for (int i = 0; i < pole.PocetRadku(); i++)
- {
- for (int j = 0; j < pole.PocetSloupcu(); j++)
- printf("%d;", pole.GetValue(i, j));
- printf("\n");
- }
- for (int i = 0; i < pole.PocetRadku(); i++)
- {
- radek = pole[i];
- for (int j = 0; j < pole.PocetSloupcu(); j++)
- printf("%d;", pole.GetValue(i, j));
- printf("\n");
- }
- // index of
- int x, y = 0, m_poz, n_poz;
- char v = 'y';
- while (v == 'y'){
- cout << "Zadej hledanou hodnotu:";
- cin >> x;
- try {
- y = 0;
- pole.IndexOf(x, &m_poz, &n_poz);
- }
- catch (string *caught) {
- cout << "Hledany prvek neexistuje!" << endl;
- y = 1;
- }
- if (y == 0)
- cout << "Hledany prvek " << x << " je na pozici [" << m_poz << " " << n_poz << "]. (Pocitano od pozice[0 0])" << endl;
- cout << "Hledat novy prvek [y/n]:";
- cin >> v;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement