Fixed flaws
This commit is contained in:
parent
3321da106c
commit
7b02ef5eda
6 changed files with 150 additions and 48 deletions
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
int readBinInt(istream &ist);
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost);
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost);
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
void my_task(istream &ist);
|
void my_task(istream &ist);
|
||||||
|
|
@ -31,49 +35,62 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int readBinInt(istream &ist) {
|
||||||
|
int x = 0;
|
||||||
|
ist.read(reinterpret_cast<char*>(&x), sizeof(int));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost) {
|
||||||
|
ost.write(reinterpret_cast<char*>(&num), sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost) {
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
int N, M;
|
int N, M;
|
||||||
ist >> N >> M;
|
ist >> N >> M;
|
||||||
ost << char(N) << char(M);
|
writeBinInt(N, ost);
|
||||||
|
writeBinInt(M, ost);
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
int cv;
|
int cv;
|
||||||
ist >> cv;
|
ist >> cv;
|
||||||
ost << char(cv);
|
writeBinInt(cv, ost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_task(istream &ist) {
|
void my_task(istream &ist) {
|
||||||
ist.seekg(0, ios::beg);
|
|
||||||
int k;
|
int k;
|
||||||
cout << "k >>>";
|
cout << "k >>>";
|
||||||
cin >> k;
|
cin >> k;
|
||||||
int N = int(ist.get()),
|
int N = readBinInt(ist),
|
||||||
M = int(ist.get());
|
M = readBinInt(ist);
|
||||||
|
if (k-1 > M) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int **mtx = new int*[N];
|
int **mtx = new int*[N];
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int *row = new int[M]();
|
int *row = new int[M]();
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
*(row + j) = int(ist.get());
|
*(row + j) = readBinInt(ist);
|
||||||
}
|
}
|
||||||
*(mtx + i) = row;
|
*(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;
|
bool flag = false;
|
||||||
|
for (int j = 1; j < M; j++) {
|
||||||
|
if (mtx[k-1][j-1] > mtx[k-1][j]) {
|
||||||
for (int v = 0; v < M; v++) {
|
for (int v = 0; v < M; v++) {
|
||||||
if (mtx[i][v] == k) {
|
if (mtx[k-1][v] == k) {
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
cout << "Line " << i + 1 << " contains k(k==" << k << ")\n";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (flag) {
|
||||||
|
cout << "Line " << k << " contains k(k==" << k << ")\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
int readBinInt(istream &ist);
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost);
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost);
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
void my_task(istream &ist);
|
void my_task(istream &ist);
|
||||||
|
|
@ -31,31 +35,44 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int readBinInt(istream &ist) {
|
||||||
|
int x = 0;
|
||||||
|
ist.read(reinterpret_cast<char*>(&x), sizeof(int));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost) {
|
||||||
|
ost.write(reinterpret_cast<char*>(&num), sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost) {
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
int N, M;
|
int N, M;
|
||||||
ist >> N >> M;
|
ist >> N >> M;
|
||||||
ost << char(N) << char(M);
|
writeBinInt(N, ost);
|
||||||
|
writeBinInt(M, ost);
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
int cv;
|
int cv;
|
||||||
ist >> cv;
|
ist >> cv;
|
||||||
ost << char(cv);
|
writeBinInt(cv, ost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_task(istream &ist) {
|
void my_task(istream &ist) {
|
||||||
ist.seekg(0, ios::beg);
|
|
||||||
int k;
|
int k;
|
||||||
cout << "k >>>";
|
cout << "k >>>";
|
||||||
cin >> k;
|
cin >> k;
|
||||||
int N = int(ist.get()),
|
int N = readBinInt(ist),
|
||||||
M = int(ist.get());
|
M = readBinInt(ist);
|
||||||
|
if (k-1 > M) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int **mtx = new int*[N];
|
int **mtx = new int*[N];
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int *row = new int[M]();
|
int *row = new int[M]();
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
*(row + j) = int(ist.get());
|
*(row + j) = readBinInt(ist);
|
||||||
}
|
}
|
||||||
*(mtx + i) = row;
|
*(mtx + i) = row;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
int readBinInt(istream &ist);
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost);
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost);
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
void my_task(istream &ist);
|
void my_task(istream &ist);
|
||||||
|
|
@ -31,31 +35,44 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int readBinInt(istream &ist) {
|
||||||
|
int x = 0;
|
||||||
|
ist.read(reinterpret_cast<char*>(&x), sizeof(int));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost) {
|
||||||
|
ost.write(reinterpret_cast<char*>(&num), sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost) {
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
int N, M;
|
int N, M;
|
||||||
ist >> N >> M;
|
ist >> N >> M;
|
||||||
ost << char(N) << char(M);
|
writeBinInt(N, ost);
|
||||||
|
writeBinInt(M, ost);
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
int cv;
|
int cv;
|
||||||
ist >> cv;
|
ist >> cv;
|
||||||
ost << char(cv);
|
writeBinInt(cv, ost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_task(istream &ist) {
|
void my_task(istream &ist) {
|
||||||
ist.seekg(0, ios::beg);
|
|
||||||
int k;
|
int k;
|
||||||
cout << "k >>>";
|
cout << "k >>>";
|
||||||
cin >> k;
|
cin >> k;
|
||||||
int N = int(ist.get()),
|
int N = readBinInt(ist),
|
||||||
M = int(ist.get());
|
M = readBinInt(ist);
|
||||||
|
if (k-1 > M) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int **mtx = new int*[N];
|
int **mtx = new int*[N];
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int *row = new int[M]();
|
int *row = new int[M]();
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
*(row + j) = int(ist.get());
|
*(row + j) = readBinInt(ist);
|
||||||
}
|
}
|
||||||
*(mtx + i) = row;
|
*(mtx + i) = row;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
int readBinInt(istream &ist);
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost);
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost);
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
void my_task(istream &ist);
|
void my_task(istream &ist);
|
||||||
|
|
@ -31,31 +35,44 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int readBinInt(istream &ist) {
|
||||||
|
int x = 0;
|
||||||
|
ist.read(reinterpret_cast<char*>(&x), sizeof(int));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost) {
|
||||||
|
ost.write(reinterpret_cast<char*>(&num), sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost) {
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
int N, M;
|
int N, M;
|
||||||
ist >> N >> M;
|
ist >> N >> M;
|
||||||
ost << char(N) << char(M);
|
writeBinInt(N, ost);
|
||||||
|
writeBinInt(M, ost);
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
int cv;
|
int cv;
|
||||||
ist >> cv;
|
ist >> cv;
|
||||||
ost << char(cv);
|
writeBinInt(cv, ost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_task(istream &ist) {
|
void my_task(istream &ist) {
|
||||||
ist.seekg(0, ios::beg);
|
|
||||||
int k;
|
int k;
|
||||||
cout << "k >>>";
|
cout << "k >>>";
|
||||||
cin >> k;
|
cin >> k;
|
||||||
int N = int(ist.get()),
|
int N = readBinInt(ist),
|
||||||
M = int(ist.get());
|
M = readBinInt(ist);
|
||||||
|
if (k-1 > M) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int **mtx = new int*[N];
|
int **mtx = new int*[N];
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int *row = new int[M]();
|
int *row = new int[M]();
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
*(row + j) = int(ist.get());
|
*(row + j) = readBinInt(ist);
|
||||||
}
|
}
|
||||||
*(mtx + i) = row;
|
*(mtx + i) = row;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
int readBinInt(istream &ist);
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost);
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost);
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
void my_task(istream &ist);
|
void my_task(istream &ist);
|
||||||
|
|
@ -31,31 +35,44 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int readBinInt(istream &ist) {
|
||||||
|
int x = 0;
|
||||||
|
ist.read(reinterpret_cast<char*>(&x), sizeof(int));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost) {
|
||||||
|
ost.write(reinterpret_cast<char*>(&num), sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost) {
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
int N, M;
|
int N, M;
|
||||||
ist >> N >> M;
|
ist >> N >> M;
|
||||||
ost << char(N) << char(M);
|
writeBinInt(N, ost);
|
||||||
|
writeBinInt(M, ost);
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
int cv;
|
int cv;
|
||||||
ist >> cv;
|
ist >> cv;
|
||||||
ost << char(cv);
|
writeBinInt(cv, ost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_task(istream &ist) {
|
void my_task(istream &ist) {
|
||||||
ist.seekg(0, ios::beg);
|
|
||||||
int k;
|
int k;
|
||||||
cout << "k >>>";
|
cout << "k >>>";
|
||||||
cin >> k;
|
cin >> k;
|
||||||
int N = int(ist.get()),
|
int N = readBinInt(ist),
|
||||||
M = int(ist.get());
|
M = readBinInt(ist);
|
||||||
|
if (k-1 > M) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int **mtx = new int*[N];
|
int **mtx = new int*[N];
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int *row = new int[M]();
|
int *row = new int[M]();
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
*(row + j) = int(ist.get());
|
*(row + j) = readBinInt(ist);
|
||||||
}
|
}
|
||||||
*(mtx + i) = row;
|
*(mtx + i) = row;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
int readBinInt(istream &ist);
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost);
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost);
|
void text2bin(istream &ist, ostream &ost);
|
||||||
|
|
||||||
void my_task(istream &ist);
|
void my_task(istream &ist);
|
||||||
|
|
@ -31,31 +35,44 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int readBinInt(istream &ist) {
|
||||||
|
int x = 0;
|
||||||
|
ist.read(reinterpret_cast<char*>(&x), sizeof(int));
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeBinInt(int num, ostream &ost) {
|
||||||
|
ost.write(reinterpret_cast<char*>(&num), sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
void text2bin(istream &ist, ostream &ost) {
|
void text2bin(istream &ist, ostream &ost) {
|
||||||
int N, M;
|
int N, M;
|
||||||
ist >> N >> M;
|
ist >> N >> M;
|
||||||
ost << char(N) << char(M);
|
writeBinInt(N, ost);
|
||||||
|
writeBinInt(M, ost);
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
int cv;
|
int cv;
|
||||||
ist >> cv;
|
ist >> cv;
|
||||||
ost << char(cv);
|
writeBinInt(cv, ost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_task(istream &ist) {
|
void my_task(istream &ist) {
|
||||||
ist.seekg(0, ios::beg);
|
|
||||||
int k;
|
int k;
|
||||||
cout << "k >>>";
|
cout << "k >>>";
|
||||||
cin >> k;
|
cin >> k;
|
||||||
int N = int(ist.get()),
|
int N = readBinInt(ist),
|
||||||
M = int(ist.get());
|
M = readBinInt(ist);
|
||||||
|
if (k-1 > M) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int **mtx = new int*[N];
|
int **mtx = new int*[N];
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
int *row = new int[M]();
|
int *row = new int[M]();
|
||||||
for (int j = 0; j < M; j++) {
|
for (int j = 0; j < M; j++) {
|
||||||
*(row + j) = int(ist.get());
|
*(row + j) = readBinInt(ist);
|
||||||
}
|
}
|
||||||
*(mtx + i) = row;
|
*(mtx + i) = row;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue