Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cuda_runtime.h"
- #include "device_launch_parameters.h"
- #include <iostream>
- #include <string>
- #include <math.h>
- #include <ctime>
- #include <stdio.h>
- using namespace std;
- const short L = 4;
- int main()
- {
- const clock_t begin_time = clock();
- int Register[L][L] = { {0,0,0,1}, {1,1,1,0}, {0,1,1,0}, {0,0,1,1} };
- int Q[L] = { 1,0,0,0 };
- int newQ[L];
- bool* tab = new bool[(int)pow(2, L) - 1];
- bool isMax = true;
- int dec;
- for (int i = 0; i < pow(2, L); i++)
- {
- tab[i] = false;
- }
- for (int i = 0; i < L; i++)
- {
- for (int j = 0; j < L; j++)
- {
- cout << endl;
- }
- }
- cout << endl;
- dec = 0;
- for (int i = 0; i < L; i++)
- {
- dec += Q[L - i - 1] * pow(2, L - i - 1);
- cout << Q[L - i - 1] << " ";
- }
- cout << " decimal: " << dec << endl;
- for (int k = 0; k < pow(2, L) - 1; k++)
- {
- for (int i = 0; i < L; i++)
- {
- int temp = 0;
- for (int j = 0; j < L; j++)
- {
- temp += Register[i][j] * Q[j];
- }
- newQ[i] = temp % 2;
- }
- dec = 0;
- for (int i = 0; i < L; i++)
- {
- Q[L - i - 1] = newQ[L - i - 1];
- dec += Q[L - i - 1] * pow(2, L - i - 1);
- cout << newQ[L - i - 1] << " ";
- }
- cout << " decimal: " << dec << endl;
- if (!tab[dec])
- {
- tab[dec] = true;
- }
- else
- {
- isMax = false;
- break;
- }
- }
- if (isMax)
- {
- cout << "CYKL MAKSYMALNY";
- }
- else
- {
- cout << "CYKL NIEMAKSYMALNY";
- }
- cout << endl;
- cout << float(clock() - begin_time) / CLOCKS_PER_SEC;
- cout << endl;
- system("pasue");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement