-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (38 loc) · 1.27 KB
/
main.cpp
File metadata and controls
48 lines (38 loc) · 1.27 KB
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
#include <fstream>
#include"gaussalgorithm.h"
using namespace std;
int main(){
/*
the intud data must be stored in the "input.txt" file
in the folloving form:
n m
<matrixLine 1> <freeMember 1>
<matrixLine 2> <freeMember 2>
................................
<matrixLine m> <freeMember m>
where n = numberOfVariables, m = numberOfEquations
*/
GaussAlgorithm ga;
ifstream file("input.txt");
ga.readFrom(file);
int numberOfTreads = 0;
cout << "Enter number of threads: ";
cin >> numberOfTreads;
while (numberOfTreads <= 0){
cout << endl;
cout << "This number must be nonegative! " << endl;
cout << "Enter number of threads: ";
cin >> numberOfTreads;
}
int numberOfSolutions = ga.findSolution(numberOfTreads);
if (numberOfSolutions == 0) cout << "There is not any solution!";
else {
if(numberOfSolutions > 1) cout << "Thre are unlimit number of solutions!\n" <<
"This is one of them: "<<endl;
const double* solution = ga.getSolution();
int n = ga.getNumberOfVariables();
for(int i = 0; i < n; i++)
cout << "x" << i << " = " << solution[i] << endl;
}
return 0;
}