[1sem]Fixed messed up sheeeeet
This commit is contained in:
parent
8fdc6de8c1
commit
b422362bcd
1 changed files with 35 additions and 60 deletions
|
|
@ -1,75 +1,50 @@
|
||||||
// pb_15_100.cpp
|
// pb_13_100.cpp
|
||||||
// Горбацевич Андрей
|
// Горбацевич Андрей
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost);
|
void print_mtx(int **mtx, int w, int h, ostream &ost);
|
||||||
|
int **generate_mtx(int n);
|
||||||
|
|
||||||
void my_task(istream &ist);
|
int main()
|
||||||
|
{
|
||||||
int main() {
|
ofstream fout("out.txt", ios::trunc);
|
||||||
ifstream ifs("in.txt");
|
if (!fout.is_open())
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
text2bin(ifs, ofs);
|
int n;
|
||||||
my_task(ifs);
|
cout << "n >>>";
|
||||||
|
cin >> n;
|
||||||
return 0;
|
int **mtx = generate_mtx(n);
|
||||||
|
print_mtx(mtx, n, n, fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost) {
|
void print_mtx(int **mtx, int w, int h, ostream &ost) {
|
||||||
int N, M;
|
for (int i = 0; i < w; i++) {
|
||||||
ist >> N >> M;
|
for (int j = 0; j < h; j++) {
|
||||||
ost << N << ' ' << M;
|
ost << *(*(mtx + i) + j) << " ";
|
||||||
for (int i = 0; i < N; i++) {
|
}
|
||||||
ost << endl;
|
ost << endl;
|
||||||
for (int j = 0; j < M; j++) {
|
}
|
||||||
int cv;
|
ost << endl;
|
||||||
ist >> cv;
|
|
||||||
ost << cv << ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_task(istream &ist) {
|
int **generate_mtx(int n) {
|
||||||
ist.seekg(0, ios::beg);
|
int **mtx = new int*[n];
|
||||||
int k;
|
for (int i = 0; i < n; i++) {
|
||||||
cout << "k >>>";
|
int *row = new int[n]();
|
||||||
cin >> k;
|
int pos = n;
|
||||||
int N, M;
|
for (int j = -n+i; j < 0; j++) {
|
||||||
ist >> N >> M;
|
*(row + pos--) = abs(j);
|
||||||
int **mtx = new int*[N];
|
}
|
||||||
for (int i = 0; i < N; i++) {
|
for (int j = 0; pos >= 0; j++) {
|
||||||
int *row = new int[M]();
|
*(row + pos--) = abs(j);
|
||||||
for (int j = 0; j < M; j++) {
|
}
|
||||||
int cv;
|
*(mtx + i) = row;
|
||||||
ist >> cv;
|
}
|
||||||
*(row + j) = cv;
|
return mtx;
|
||||||
}
|
|
||||||
*(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