while (!(cin >> D[m]))
while (!(cin >> D[i]))
cout << "Введите кол-во массивов: ";
cout << "Введите кол-во элементов массива ";
git remote add origin ssh://server.com/home/username/git/exampleproject
git clone ssh://server.com/home/username/git/exampleproject
_ [a-z] [0-9] [=] ¬
s0 s1 s2 ok end
s1 s1 s1 ok ok
s2 ok s2 ok ok
_ in == ['a'-'z'] in == ['0'-'9'] in == ['='] ¬
s0 val := in; next; s1 val := in-'0'; next; s2 next; ret(ASSIGN) ret(EOT)
s1 val := concat(val, in); next; s1 val := concat(val, in); next; s1 ret(IDENT, val) ret(IDENT, val)
s2 ret(INTEGER, val) val := val*10+in-'0'; next; s2 ret(INTEGER, val) ret(INTEGER, val)
s0 ('a') -> val := 'a'; next; s1
s1 ('1') -> val := 'a1'; next; s1
s1 ('=') -> ret(IDENT, 'a1')
s0 ('=') -> next; ret(ASSIGN)
s0 ('9') -> val := 9; next; s2
s2 ('5') -> val := 95; next; s2
s2 (¬) -> ret(INTEGER, 95)
s0 (¬) -> ret(EOT)
#include <iostream>
#include <vector>
#include <climits>
#include <map>
#include <ctime>
class MyMatrixInt {
public:
MyMatrixInt(size_t rows = 1, size_t cols = 1, int range = 1)
{
reFill(rows, cols, range);
}
void reFill(size_t rows = 1, size_t cols = 1, int range = 1)
{
data_.clear();
for (size_t i = 0; i < rows; ++i) {
std::vector<int> row;
for (size_t j = 0; j < cols; ++j) {
row.push_back(rand() % range);
}
data_.push_back(row);
}
}
int maxUniqueElem() const
{
int max_elem = INT_MIN;
std::map<int, int> elem_map;
for (size_t i = 0; i < data_.size(); i++) {
for (size_t j = 0; j < data_[i].size(); j++) {
elem_map[data_[i][j]]++;
}
}
std::map<int, int>::reverse_iterator rit;
for (rit = elem_map.rbegin(); rit != elem_map.rend(); ++rit) {
if (rit->second == 1) {
max_elem = rit->first;
break;
}
}
return max_elem;
}
void print() const
{
for (size_t i = 0; i < data_.size(); ++i) {
for (size_t j = 0; j < data_[0].size(); j++) {
std::cout << data_[i][j] << "\t";
}
std::cout << std::endl;
}
}
private:
std::vector<std::vector<int> > data_;
};
int main()
{
MyMatrixInt my_mat;
//srand(time(NULL));
my_mat.reFill(5, 5, 10); // Fill 2D 5x5 Matrix
my_mat.print();
int max = my_mat.maxUniqueElem();
if (max != INT_MIN) {
std::cout << "\nMax element is: " << max << std::endl;
}
else {
std::cout << "\nMax element in matrix isn't found!" << std::endl;
}
return 0;
}
A path consists of a sequence of path segments separated by a slash
("/") character.