-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
67 lines (59 loc) · 1.23 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// test.cpp: îïðåäåëÿåò òî÷êó âõîäà äëÿ êîíñîëüíîãî ïðèëîæåíèÿ.
//
#include "header.h"
#include "matrix.h"
int main()
{
std::ifstream w("test.txt");
std::string in;
std::string out;
while (w >> in >> out)
{
in = "tests/" + in;
out = "tests/" + out;
std::ifstream fin(in);
std::ofstream fout(out);
try
{
if (!fin.is_open())
throw std::logic_error("no file!");
int a, b;
bool che = fin.eof();
if (!(fin >> a >> b))
throw std::logic_error("empty file!");
std::string y;
std::getline(fin, y);
if (!y.empty())
throw std::logic_error("wrong input!");
std::valarray<std::valarray<std::string>> m(std::valarray<std::string>(a + 2), b);
for (int i = 0; i < b; i++)
{
for (int j = 0; j < a + 2; j++)
{
if (fin.eof())
throw std::logic_error("bad input!");
fin >> m[i][j];
}
}
if (!fin.eof())
throw std::logic_error("bad input!");
matrix mat(a, b);
mat.input(m);
mat.deistv();
auto p = mat.output();
for (auto i : p.second)
{
fout << i << ' ';
}
fout << std::endl << p.first;
}
catch (std::exception e)
{
fout << "something going wrong! - " << e.what() << std::endl;
}
fin.close();
fout.close();
}
w.close();
return 0;
}