SHARE
TWEET

Farbe

pabloducato May 31st, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. int main()
  3. {
  4.     const int VERT_NUM = 7; // Wprowadź ilość wierzchołków
  5.     const int COLOR_NUM = 3; // Wprowadź ilość kolorów
  6.     const int EDG_NUM = 9; // Wprowadź ilość krawędzi
  7.     int vertices[VERT_NUM] = {0};
  8.     int edges[EDG_NUM][2];
  9.     // Wprowadź wierzchołki kolejnych krawędzi (numeracja zaczyna się od 1)
  10.     edges[0][0] = 1, edges[0][1] = 2; // 1. krawędź
  11.     edges[1][0] = 1, edges[1][1] = 3; // 2. krawędź
  12.     edges[2][0] = 1, edges[2][1] = 6; // ...
  13.     edges[3][0] = 2, edges[3][1] = 5;
  14.     edges[4][0] = 3, edges[4][1] = 6;
  15.     edges[5][0] = 3, edges[5][1] = 4;
  16.     edges[6][0] = 4, edges[6][1] = 5;
  17.     edges[7][0] = 5, edges[7][1] = 6;
  18.     edges[8][0] = 5, edges[8][1] = 7;
  19.     bool right = true;
  20.     int counter = 0;
  21.     while (true)
  22.     {
  23.         for (int i = 0; i < EDG_NUM; i++)
  24.         {
  25.             if (vertices[edges[i][0] - 1] == vertices[edges[i][1] - 1])
  26.             {
  27.                 right = false;
  28.                 break;
  29.             }
  30.         }
  31.         if (right)
  32.         {
  33.             counter++;
  34.             std::cout << "GRAF " << counter << std::endl;
  35.             for (int i = 0; i < VERT_NUM; i++)
  36.                 std::cout << vertices[i] << ' ';
  37.             std::cout << std::endl;
  38.         }
  39.         vertices[0]++;
  40.         for (int i = 0; i < VERT_NUM - 1; i++)
  41.         {
  42.             if (vertices[i] == COLOR_NUM)
  43.             {
  44.                 vertices[i] = 0;
  45.                 vertices[i + 1]++;
  46.             }
  47.         }
  48.         if (vertices[VERT_NUM - 1] == COLOR_NUM)
  49.             break;
  50.         right = true;
  51.     }
  52.     std::cin.get();
  53.     return 0;
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top