[2sem]Fixed bp/15
This commit is contained in:
parent
b324015452
commit
8fdc6de8c1
7 changed files with 564 additions and 36 deletions
|
|
@ -1,50 +1,75 @@
|
||||||
// pb_13_100.cpp
|
// pb_15_100.cpp
|
||||||
// Горбацевич Андрей
|
// Горбацевич Андрей
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void print_mtx(int **mtx, int w, int h, ostream &ost);
|
void text2bin(istream &ist, ostream &ost);
|
||||||
int **generate_mtx(int n);
|
|
||||||
|
|
||||||
int main()
|
void my_task(istream &ist);
|
||||||
{
|
|
||||||
ofstream fout("out.txt", ios::trunc);
|
int main() {
|
||||||
if (!fout.is_open())
|
ifstream ifs("in.txt");
|
||||||
|
ofstream ofs("out.bin", ios::trunc|ios::binary);
|
||||||
|
if (!ifs.is_open())
|
||||||
{
|
{
|
||||||
cerr << "Unable to open file" << endl;
|
cerr << "Unable to open file" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int n;
|
text2bin(ifs, ofs);
|
||||||
cout << "n >>>";
|
my_task(ifs);
|
||||||
cin >> n;
|
|
||||||
int **mtx = generate_mtx(n);
|
return 0;
|
||||||
print_mtx(mtx, n, n, fout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_mtx(int **mtx, int w, int h, ostream &ost) {
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
for (int i = 0; i < w; i++) {
|
int N, M;
|
||||||
for (int j = 0; j < h; j++) {
|
ist >> N >> M;
|
||||||
ost << *(*(mtx + i) + j) << " ";
|
ost << N << ' ' << M;
|
||||||
}
|
for (int i = 0; i < N; i++) {
|
||||||
ost << endl;
|
ost << endl;
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
int cv;
|
||||||
|
ist >> cv;
|
||||||
|
ost << cv << ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ost << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int **generate_mtx(int n) {
|
void my_task(istream &ist) {
|
||||||
int **mtx = new int*[n];
|
ist.seekg(0, ios::beg);
|
||||||
for (int i = 0; i < n; i++) {
|
int k;
|
||||||
int *row = new int[n]();
|
cout << "k >>>";
|
||||||
int pos = n;
|
cin >> k;
|
||||||
for (int j = -n+i; j < 0; j++) {
|
int N, M;
|
||||||
*(row + pos--) = abs(j);
|
ist >> N >> M;
|
||||||
}
|
int **mtx = new int*[N];
|
||||||
for (int j = 0; pos >= 0; j++) {
|
for (int i = 0; i < N; i++) {
|
||||||
*(row + pos--) = abs(j);
|
int *row = new int[M]();
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
int cv;
|
||||||
|
ist >> cv;
|
||||||
|
*(row + j) = cv;
|
||||||
}
|
}
|
||||||
*(mtx + i) = row;
|
*(mtx + i) = row;
|
||||||
}
|
}
|
||||||
return mtx;
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 1; j < M; j++) {
|
||||||
|
if (mtx[i][j-1] < mtx[i][j]) {
|
||||||
|
bool flag = false;
|
||||||
|
for (int v = 0; v < M; v++) {
|
||||||
|
if (mtx[i][v] == k) {
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
cout << "Line " << i + 1 << " contains k(k==" << k << ")\n";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
79
2sem/programming basics/15/100.cpp
Normal file
79
2sem/programming basics/15/100.cpp
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
// pb_15_100_v5.cpp
|
||||||
|
// Горбацевич Андрей
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
|
void my_task(istream &ist);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string path_in = "in.txt"; // путь до входного файла
|
||||||
|
string path_out = "out.bin"; // путь до выходного файла
|
||||||
|
|
||||||
|
ifstream ifs(path_in);
|
||||||
|
ofstream ofs(path_out, ios::binary);
|
||||||
|
if (!ifs.is_open())
|
||||||
|
{
|
||||||
|
cerr << "Unable to open file" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
text2bin(ifs, ofs);
|
||||||
|
ifs.close();
|
||||||
|
ofs.close();
|
||||||
|
|
||||||
|
ifstream binfs(path_out, ios::binary);
|
||||||
|
my_task(binfs);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
|
int N, M;
|
||||||
|
ist >> N >> M;
|
||||||
|
ost << char(N) << char(M);
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
int cv;
|
||||||
|
ist >> cv;
|
||||||
|
ost << char(cv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_task(istream &ist) {
|
||||||
|
ist.seekg(0, ios::beg);
|
||||||
|
int k;
|
||||||
|
cout << "k >>>";
|
||||||
|
cin >> k;
|
||||||
|
int N = int(ist.get()),
|
||||||
|
M = int(ist.get());
|
||||||
|
int **mtx = new int*[N];
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
int *row = new int[M]();
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
*(row + j) = int(ist.get());
|
||||||
|
}
|
||||||
|
*(mtx + i) = row;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 1; j < M; j++) {
|
||||||
|
if (mtx[i][j-1] < mtx[i][j]) {
|
||||||
|
bool flag = false;
|
||||||
|
for (int v = 0; v < M; v++) {
|
||||||
|
if (mtx[i][v] == k) {
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
cout << "Line " << i + 1 << " contains k(k==" << k << ")\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
90
2sem/programming basics/15/additional/100_1.cpp
Normal file
90
2sem/programming basics/15/additional/100_1.cpp
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
// pb_15_100_v1.cpp
|
||||||
|
// Горбацевич Андрей
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
|
void my_task(istream &ist);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string path_in = "in.txt"; // путь до входного файла
|
||||||
|
string path_out = "out.bin"; // путь до выходного файла
|
||||||
|
|
||||||
|
ifstream ifs(path_in);
|
||||||
|
ofstream ofs(path_out, ios::binary);
|
||||||
|
if (!ifs.is_open())
|
||||||
|
{
|
||||||
|
cerr << "Unable to open file" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
text2bin(ifs, ofs);
|
||||||
|
ifs.close();
|
||||||
|
ofs.close();
|
||||||
|
|
||||||
|
ifstream binfs(path_out, ios::binary);
|
||||||
|
my_task(binfs);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
|
int N, M;
|
||||||
|
ist >> N >> M;
|
||||||
|
ost << char(N) << char(M);
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
int cv;
|
||||||
|
ist >> cv;
|
||||||
|
ost << char(cv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_task(istream &ist) {
|
||||||
|
ist.seekg(0, ios::beg);
|
||||||
|
int k;
|
||||||
|
cout << "k >>>";
|
||||||
|
cin >> k;
|
||||||
|
int N = int(ist.get()),
|
||||||
|
M = int(ist.get());
|
||||||
|
int **mtx = new int*[N];
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
int *row = new int[M]();
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
*(row + j) = int(ist.get());
|
||||||
|
}
|
||||||
|
*(mtx + i) = row;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
bool flag = true;
|
||||||
|
int *row = mtx[i];
|
||||||
|
for (int j = 1; j < M; j++) {
|
||||||
|
if (row[j-1] < row[j]) {
|
||||||
|
flag = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
int l = 0,
|
||||||
|
r = M-1;
|
||||||
|
int m;
|
||||||
|
while (l<=r) {
|
||||||
|
m = (l+r) / 2;
|
||||||
|
if (k < row[m]) {
|
||||||
|
l = m+1;
|
||||||
|
}
|
||||||
|
else if (k > row[m]) {
|
||||||
|
r = m-1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "Line " << i + 1 << " is descending and contains k(k==" << k << ")\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
83
2sem/programming basics/15/additional/100_2.cpp
Normal file
83
2sem/programming basics/15/additional/100_2.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
// pb_15_100_v2.cpp
|
||||||
|
// Горбацевич Андрей
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
|
void my_task(istream &ist);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string path_in = "in.txt"; // путь до входного файла
|
||||||
|
string path_out = "out.bin"; // путь до выходного файла
|
||||||
|
|
||||||
|
ifstream ifs(path_in);
|
||||||
|
ofstream ofs(path_out, ios::binary);
|
||||||
|
if (!ifs.is_open())
|
||||||
|
{
|
||||||
|
cerr << "Unable to open file" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
text2bin(ifs, ofs);
|
||||||
|
ifs.close();
|
||||||
|
ofs.close();
|
||||||
|
|
||||||
|
ifstream binfs(path_out, ios::binary);
|
||||||
|
my_task(binfs);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
|
int N, M;
|
||||||
|
ist >> N >> M;
|
||||||
|
ost << char(N) << char(M);
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
int cv;
|
||||||
|
ist >> cv;
|
||||||
|
ost << char(cv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_task(istream &ist) {
|
||||||
|
ist.seekg(0, ios::beg);
|
||||||
|
int k;
|
||||||
|
cout << "k >>>";
|
||||||
|
cin >> k;
|
||||||
|
int N = int(ist.get()),
|
||||||
|
M = int(ist.get());
|
||||||
|
int **mtx = new int*[N];
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
int *row = new int[M]();
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
*(row + j) = int(ist.get());
|
||||||
|
}
|
||||||
|
*(mtx + i) = row;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
bool flag = true;
|
||||||
|
int *row = mtx[i];
|
||||||
|
int *ic = new int[M]();
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
for (int k = j+1; k < M; k++) {
|
||||||
|
if (row[j] == row[k]) {
|
||||||
|
ic[j] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int mx = ic[0],
|
||||||
|
mxp = 0;
|
||||||
|
for (int j = 1; j < M; j++) {
|
||||||
|
if (mx < ic[j]) {
|
||||||
|
mx = ic[j];
|
||||||
|
mxp = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << "Most common on line " << i+1 << ": " << row[mxp] << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
90
2sem/programming basics/15/additional/100_3.cpp
Normal file
90
2sem/programming basics/15/additional/100_3.cpp
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
// pb_15_100_v3.cpp
|
||||||
|
// Горбацевич Андрей
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
|
void my_task(istream &ist);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string path_in = "in.txt"; // путь до входного файла
|
||||||
|
string path_out = "out.bin"; // путь до выходного файла
|
||||||
|
|
||||||
|
ifstream ifs(path_in);
|
||||||
|
ofstream ofs(path_out, ios::binary);
|
||||||
|
if (!ifs.is_open())
|
||||||
|
{
|
||||||
|
cerr << "Unable to open file" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
text2bin(ifs, ofs);
|
||||||
|
ifs.close();
|
||||||
|
ofs.close();
|
||||||
|
|
||||||
|
ifstream binfs(path_out, ios::binary);
|
||||||
|
my_task(binfs);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
|
int N, M;
|
||||||
|
ist >> N >> M;
|
||||||
|
ost << char(N) << char(M);
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
int cv;
|
||||||
|
ist >> cv;
|
||||||
|
ost << char(cv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_task(istream &ist) {
|
||||||
|
ist.seekg(0, ios::beg);
|
||||||
|
int k;
|
||||||
|
cout << "k >>>";
|
||||||
|
cin >> k;
|
||||||
|
int N = int(ist.get()),
|
||||||
|
M = int(ist.get());
|
||||||
|
int **mtx = new int*[N];
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
int *row = new int[M]();
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
*(row + j) = int(ist.get());
|
||||||
|
}
|
||||||
|
*(mtx + i) = row;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
bool flag = true;
|
||||||
|
int *row = mtx[i];
|
||||||
|
for (int j = 1; j < M; j++) {
|
||||||
|
if (row[j-1] > row[j]) {
|
||||||
|
flag = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
int l = 0,
|
||||||
|
r = M-1;
|
||||||
|
int m;
|
||||||
|
while (l<=r) {
|
||||||
|
m = (l+r) / 2;
|
||||||
|
if (k > row[m]) {
|
||||||
|
l = m+1;
|
||||||
|
}
|
||||||
|
else if (k < row[m]) {
|
||||||
|
r = m-1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "Line " << i + 1 << " is ascending and contains k(k==" << k << ")\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
82
2sem/programming basics/15/additional/100_4.cpp
Normal file
82
2sem/programming basics/15/additional/100_4.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
// pb_15_100_v4.cpp
|
||||||
|
// Горбацевич Андрей
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
|
void my_task(istream &ist);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string path_in = "in.txt"; // путь до входного файла
|
||||||
|
string path_out = "out.bin"; // путь до выходного файла
|
||||||
|
|
||||||
|
ifstream ifs(path_in);
|
||||||
|
ofstream ofs(path_out, ios::binary);
|
||||||
|
if (!ifs.is_open())
|
||||||
|
{
|
||||||
|
cerr << "Unable to open file" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
text2bin(ifs, ofs);
|
||||||
|
ifs.close();
|
||||||
|
ofs.close();
|
||||||
|
|
||||||
|
ifstream binfs(path_out, ios::binary);
|
||||||
|
my_task(binfs);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
|
int N, M;
|
||||||
|
ist >> N >> M;
|
||||||
|
ost << char(N) << char(M);
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
int cv;
|
||||||
|
ist >> cv;
|
||||||
|
ost << char(cv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_task(istream &ist) {
|
||||||
|
ist.seekg(0, ios::beg);
|
||||||
|
int k;
|
||||||
|
cout << "k >>>";
|
||||||
|
cin >> k;
|
||||||
|
int N = int(ist.get()),
|
||||||
|
M = int(ist.get());
|
||||||
|
int **mtx = new int*[N];
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
int *row = new int[M]();
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
*(row + j) = int(ist.get());
|
||||||
|
}
|
||||||
|
*(mtx + i) = row;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
int *row = mtx[i];
|
||||||
|
bool flag = true;
|
||||||
|
for (int sk = 1; sk <= k; sk++) {
|
||||||
|
bool cc = false;
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
if (row[j] == sk) {
|
||||||
|
cc = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!cc) {
|
||||||
|
flag = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
cout << "Line " << i+1 << " contains every number in 1..." << k << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
79
2sem/programming basics/15/additional/100_5.cpp
Normal file
79
2sem/programming basics/15/additional/100_5.cpp
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
// pb_15_100_v5.cpp
|
||||||
|
// Горбацевич Андрей
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
|
void my_task(istream &ist);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string path_in = "in.txt"; // путь до входного файла
|
||||||
|
string path_out = "out.bin"; // путь до выходного файла
|
||||||
|
|
||||||
|
ifstream ifs(path_in);
|
||||||
|
ofstream ofs(path_out, ios::binary);
|
||||||
|
if (!ifs.is_open())
|
||||||
|
{
|
||||||
|
cerr << "Unable to open file" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
text2bin(ifs, ofs);
|
||||||
|
ifs.close();
|
||||||
|
ofs.close();
|
||||||
|
|
||||||
|
ifstream binfs(path_out, ios::binary);
|
||||||
|
my_task(binfs);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
|
int N, M;
|
||||||
|
ist >> N >> M;
|
||||||
|
ost << char(N) << char(M);
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
int cv;
|
||||||
|
ist >> cv;
|
||||||
|
ost << char(cv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void my_task(istream &ist) {
|
||||||
|
ist.seekg(0, ios::beg);
|
||||||
|
int k;
|
||||||
|
cout << "k >>>";
|
||||||
|
cin >> k;
|
||||||
|
int N = int(ist.get()),
|
||||||
|
M = int(ist.get());
|
||||||
|
int **mtx = new int*[N];
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
int *row = new int[M]();
|
||||||
|
for (int j = 0; j < M; j++) {
|
||||||
|
*(row + j) = int(ist.get());
|
||||||
|
}
|
||||||
|
*(mtx + i) = row;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
for (int j = 1; j < M; j++) {
|
||||||
|
if (mtx[i][j-1] < mtx[i][j]) {
|
||||||
|
bool flag = false;
|
||||||
|
for (int v = 0; v < M; v++) {
|
||||||
|
if (mtx[i][v] == k) {
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
cout << "Line " << i + 1 << " contains k(k==" << k << ")\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue