Advertisement
rihardmarius

generadores de Z25 con mult

Sep 7th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <array>
  3. using namespace std;
  4.  
  5. void generar (int a)
  6. {
  7.     int c=1;
  8.     int primer = a;
  9.     cout << a;
  10.     a = a*primer%25;
  11.     while (a != primer)
  12.     {
  13.         cout << ", " << a;
  14.         a = a*primer%25;
  15.         c++;
  16.     }
  17.     cout << "}\n";
  18.     cout << "|<" << primer << ">| = " << c << "\n\n";
  19. }
  20.  
  21. int main()
  22. {
  23.     int n=0;
  24.     array<int,20> z25;
  25.     for (int i=0; i<20; i++)
  26.     {
  27.         n++;
  28.         if(n % 5 != 0)
  29.             z25.at(i) = n;
  30.         else
  31.             i--;
  32.     }
  33.  
  34.     for (int i=0; i<20; i++)
  35.     {
  36.         cout << '<' << z25.at(i) << "> = {";
  37.         generar(z25.at(i));
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement