Advertisement
Metrowy

onkgCPU

Nov 13th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include "cuda_runtime.h"
  2. #include "device_launch_parameters.h"
  3. #include <iostream>
  4. #include <string>
  5. #include <math.h>
  6. #include <ctime>
  7.  
  8. #include <stdio.h>
  9. using namespace std;
  10.  
  11. const short L = 4;
  12.  
  13. int main()
  14. {
  15.     const clock_t begin_time = clock();
  16.  
  17.     int Register[L][L] = { {0,0,0,1}, {1,1,1,0}, {0,1,1,0}, {0,0,1,1} };
  18.     int Q[L] = { 1,0,0,0 };
  19.     int newQ[L];
  20.     bool* tab = new bool[(int)pow(2, L) - 1];
  21.     bool isMax = true;
  22.     int dec;
  23.  
  24.     for (int i = 0; i < pow(2, L); i++)
  25.     {
  26.         tab[i] = false;
  27.     }
  28.     for (int i = 0; i < L; i++)
  29.     {
  30.         for (int j = 0; j < L; j++)
  31.         {
  32.             cout << endl;
  33.         }
  34.     }
  35.     cout << endl;
  36.  
  37.     dec = 0;
  38.     for (int i = 0; i < L; i++)
  39.     {
  40.         dec += Q[L - i - 1] * pow(2, L - i - 1);
  41.         cout << Q[L - i - 1] << " ";
  42.     }
  43.     cout << " decimal: " << dec << endl;
  44.  
  45.     for (int k = 0; k < pow(2, L) - 1; k++)
  46.     {
  47.         for (int i = 0; i < L; i++)
  48.         {
  49.             int temp = 0;
  50.             for (int j = 0; j < L; j++)
  51.             {
  52.                 temp += Register[i][j] * Q[j];
  53.             }
  54.             newQ[i] = temp % 2;
  55.         }
  56.         dec = 0;
  57.         for (int i = 0; i < L; i++)
  58.         {
  59.             Q[L - i - 1] = newQ[L - i - 1];
  60.             dec += Q[L - i - 1] * pow(2, L - i - 1);
  61.             cout << newQ[L - i - 1] << " ";
  62.         }
  63.         cout << " decimal: " << dec << endl;
  64.  
  65.         if (!tab[dec])
  66.         {
  67.             tab[dec] = true;
  68.         }
  69.         else
  70.         {
  71.             isMax = false;
  72.             break;
  73.         }
  74.     }
  75.  
  76.     if (isMax)
  77.     {
  78.         cout << "CYKL MAKSYMALNY";
  79.     }
  80.     else
  81.     {
  82.         cout << "CYKL NIEMAKSYMALNY";
  83.     }
  84.  
  85.     cout << endl;
  86.     cout << float(clock() - begin_time) / CLOCKS_PER_SEC;
  87.     cout << endl;
  88.     system("pasue");
  89.    
  90.    
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement