bogdanNiculeasa

Schelet problema polihroniade

Mar 3rd, 2022
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>>
  3.  
  4. using namespace std;
  5.  
  6. void displayMatrix(int matrix[1000][1000], int n);
  7. void getSolution(int p, int matrix[1000][1000]);
  8. void displayNumberOfSwapsToTransformToChessBoard(int matrix[1000][1000]);
  9. void checkIfMatrixCanBeChessBoard(int matrix[1000][1000]);
  10. void findMinSwapsToTransformToChessBoard(int matrix[1000][1000]);
  11.  
  12. int main()
  13. {
  14.     ifstream fin("polihroniade.in");
  15.     // ofstream fout("polihroniade.out");
  16.     int p, t;
  17.     fin >> p >> t;
  18.     int currentScenario = 1;
  19.     while (currentScenario <= t)
  20.     {
  21.         int n;
  22.         fin >> n;
  23.         int matrix[1000][1000] = {0};
  24.  
  25.         for (int i = 0; i < n; i++)
  26.         {
  27.             char line[n];
  28.             fin >> line;
  29.             for (int j = 0; j <  n; j++)
  30.             {
  31.                 matrix[i][j] = line[j] - '0';
  32.             }
  33.         }
  34.         //displayMatrix(matrix, n); // asta e doar de verificare sa vezi daca ti-a citit cum trebuie
  35.         getSolution(p, matrix);
  36.         currentScenario++;
  37.     }
  38.     return 0;
  39. }
  40.  
  41. void displayMatrix(int matrix[1000][1000], int n) {
  42.     for (int i = 0; i < n; i++) {
  43.         for (int j = 0; j < n; j++) {
  44.             cout << matrix[i][j] << " ";
  45.         }
  46.         cout << endl;
  47.     }
  48.     cout << endl << endl;
  49. }
  50.  
  51. void getSolution(int p, int matrix[1000][1000]) {
  52.     switch (p) {
  53.         case 1:
  54.         checkIfMatrixCanBeChessBoard(matrix);
  55.         break;
  56.     case 2:
  57.         findMinSwapsToTransformToChessBoard(matrix);
  58.         break;
  59.     case 3:
  60.         displayNumberOfSwapsToTransformToChessBoard(matrix);
  61.         break;
  62.     default:
  63.         break;
  64.     }
  65. }
  66.  
  67. void checkIfMatrixCanBeChessBoard(int matrix[1000][1000]) {
  68.     cout << "Aici vom implementa daca matricea poate sa fie sau nu o tabla de sah" << endl;
  69. }
  70.  
  71. void findMinSwapsToTransformToChessBoard(int matrix[1000][1000]) {
  72.     cout << "Aici vom afla numarul minim de transformari pe care le putem face ca sa transforma in tabla de sah" << endl;
  73. }
  74.  
  75. void displayNumberOfSwapsToTransformToChessBoard(int matrix[1000][1000]) {
  76.     cout << "Aici vom face ultima cerinta, anume cand P = 3" << endl;
  77. }
  78.  
  79.  
Add Comment
Please, Sign In to add comment