Advertisement
rihardmarius

grupo multiplicativo Z25

Sep 7th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <array>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     bool b = false;
  9.     int n=0;
  10.     int m=0;
  11.     array<int,20> z25;
  12.     for (int i=0; i<20; i++) //inicializacion z25
  13.     {
  14.         n++;
  15.         if(n % 5 != 0)
  16.             z25.at(i) = n;
  17.         else
  18.             i--;
  19.     }
  20.  
  21.     array<int,20> simetricos = z25;
  22.     /*for (int i=0; i<20; i++)
  23.         cout << simetricos.at(i) << ' ';
  24.     cout << endl;
  25.     for (int i=0; i<20; i++)
  26.         cout << z25.at(i) << ' ';*/
  27.  
  28.     cout << "\nMultiplicacion de clases en Z25 - {0,5,10,15,20}\n";
  29.     cout << "\n  * |  ";
  30.     for (int i=1; i<25; i++)
  31.     {
  32.         if (i%5==0) continue;
  33.         cout << i << ' ';
  34.         if (i<9) cout << ' ';
  35.     }
  36.  
  37.     cout << "\n----+-";
  38.     for (int i=1; i<21; i++)
  39.         cout << "---";
  40.     cout << endl;
  41.     for (int i=1; i<25; i++)
  42.     {
  43.         if (i%5==0) continue;
  44.         if (i<10) cout << ' ';
  45.         cout << ' ' << i << " | ";
  46.         for (int j=1; j<25; j++)
  47.         {
  48.             if (j%5==0) continue;
  49.             if (i*j%25%5==0) return 1;
  50.             if ((i*j)%25<10) cout << ' ';
  51.  
  52.             cout << (i*j)%25 << ' ';
  53.  
  54.             if (i*j%25 == 1)
  55.             {
  56.                 simetricos.at(m) = j;
  57.                 m++;
  58.             }
  59.  
  60.             for (int k=0; k<20; k++)
  61.                 if (z25.at(k) == i*j%25)
  62.                 {
  63.                     b = true;
  64.                     break;
  65.                 }
  66.             if (not b)
  67.                 return 1;
  68.             b = false;
  69.         }
  70.  
  71.         cout << endl;
  72.     }
  73.     cout << endl;
  74.     for (int i=0; i<20; i++)
  75.     {
  76.         cout << "Simetrico de " << z25.at(i) << ": " << simetricos.at(i) << endl;
  77.     }
  78.  
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement