Created
March 5, 2015 10:21
-
-
Save kostyakoz/770eade76d8b0903e9d6 to your computer and use it in GitHub Desktop.
Matrix Linear
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Matrix Line.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
#include <iostream> | |
#include <ctime> | |
#include <Windows.h> | |
using namespace std; | |
int _tmain(int argc, _TCHAR* argv[]) | |
{ | |
srand(time(0)); | |
setlocale(LC_ALL, ""); | |
int n, m; | |
float x; | |
boolean OK; | |
cout << "Input n (string number) & m (column number): "; | |
cin >> n; cin >> m; | |
float ** ARR = new float *[n]; | |
for (int i = 0; i < n; i++) ARR[i] = new float[m]; | |
cout << "\n"; | |
for (int i = 0; i < n; i++) | |
for (int j = 0; j < m; j++) { | |
cin >> ARR[i][j]; | |
} | |
cout << "\n********** MATRIX **********\n\n"; | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < m; j++) { | |
cout << ARR[i][j] << " "; | |
} | |
cout << "\n"; | |
} | |
cout << "\n****** LINEAR STRINGS ******\n\n"; | |
for (int i = 0; i < n - 1; i++) { | |
cout << "NUM " << i << ": "; | |
for (int j = i + 1; j < n; j++) { | |
OK = true; | |
for (int k = 0; k < m; k++) { | |
if ((ARR[i][k] != 0) && (ARR[j][k] != 0)) { | |
x = ARR[i][k] / ARR[j][k]; | |
break; | |
} else if (((k - 1) == m) && (ARR[i][k] == 0) && (ARR[j][k] == 0)) OK = false; | |
} | |
if (OK) { | |
for (int k = 1; k < m; k++) { | |
if ((ARR[i][k] / ARR[j][k]) != x) { | |
OK = false; | |
break; | |
} | |
} | |
if (OK) cout << j << "; "; else cout << "-"; | |
} | |
} | |
cout << "\n"; | |
} | |
cout << "\n"; | |
for (int i = 0; i < n; i++) delete[] ARR[i]; | |
delete[] ARR; | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment