Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include<vector>
- #include <ctime>
- using namespace std;
- //vector<vector<string>> CreateDynamicMatrix( int rows, int col)
- //{
- // vector<vector<string>> vec;
- // //Grow rows by m
- // vec.resize(rows );
- // for (int i = 0; i < rows; ++i)
- // {
- // //Grow Columns by n
- // vec[i].resize(col);
- // }
- // return vec;
- //}
- //vector<int> DestinationFunction(int size)
- //{
- // srand(time(NULL));
- // vector<int> vec;
- // vec.resize(size);
- // for(int i=0;i<size;i++)
- // {
- // vec[i] = rand() % size + 1;
- // }
- //}
- //vector<vector<string>> ReadDataFromFile(string fileName)
- //{
- // ifstream file(fileName);
- // string line;
- // if (file.is_open())
- // {
- // getline(file, line);
- // cout << line << '\n';
- //
- // getline(file, line);
- // cout << line << '\n';
- //
- // //int sizeOfArray = stoi(line);
- // int sizeOfArray = 17;
- // vector<vector<string>>matrix = CreateDynamicMatrix(sizeOfArray, sizeOfArray);
- //
- //
- // string lineTest;
- // while (getline(file, lineTest))
- // {
- // for (int i = 0; i < sizeOfArray; i++)
- // {
- // for (int j = 0; j < sizeOfArray; j++)
- // {
- // file >> matrix[i][j];
- // }
- // }
- // }
- //
- // file.close();
- // return matrix;
- // }
- //
- // else cout << "Unable to open file";
- //
- //}
- int main(int argc, char* argv[])
- {
- //string matrixFile = argv[1];
- string matrixFile = "data17.txt";
- vector<vector<string>> matrix;
- string matrixx[17][17];
- matrix.resize(17);
- for (int i = 0; i < 17; ++i)
- {
- //Grow Columns by n
- matrix[i].resize(17);
- }
- int size = 0;
- //matrix = ReadDataFromFile(matrixFile);
- ifstream x(matrixFile);
- if (x.is_open())
- {
- string line;
- string s;
- getline(x, s);
- cout << s << '\n';
- getline(x, s);
- cout << s << '\n';
- int sizeOfArray = stoi(s);
- //int sizeOfArray = 17;
- //ifstream x("data17.txt");
- while(getline(x, s))
- {
- for (int i = 0; i < 17; i++)
- {
- for (int j = 0; j < 17; j++)
- {
- x >> matrixx[i][j];
- }
- }
- }
- x.close();
- }
- //string lineTest;
- /*while (getline(file, line))
- {
- for (int i = 0; i < sizeOfArray; i++)
- {
- for (int j = 0; j < sizeOfArray; j++)
- {
- file >> matrix[i][j];
- }
- }
- }*/
- else cout << "Unable to open file";
- cout << "Tablica\n";
- for (int i = 0; i < 17; i++)
- {
- for (int j = 0; j < 17; j++)
- {
- cout << matrixx[i][j] << " ";
- }
- cout << "\n";
- }
- int destinationFunc[5] = { 1,13,2,5,6 };
- int result = 0;
- int value = 0;
- for (int i = 0; i < 4; i++)
- {
- value = stoi(matrix[destinationFunc[i]-1][destinationFunc[i+1]-1]);
- result += value;
- }
- value = stoi(matrix[destinationFunc[4]-1][destinationFunc[0]-1]);
- result += value;
- cout << "Kundel bury,\nKundel bury,\nwypierdala wszystkim buly\nWynik: " << result;
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement