Advertisement
STANAANDREY

3 11/11/2019

Nov 11th, 2019
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef struct
  5. {
  6.     int f, put;
  7. } ELEM;
  8.  
  9. int main()
  10. {
  11.     ELEM e[1000];
  12.     int x, n = 0;
  13.     cout << "x=";
  14.     cin >> x;
  15.     int f = 2, p;
  16.     while (x > 1)
  17.     {
  18.         p = 0;
  19.         while (x % f == 0)
  20.         {
  21.             p++;
  22.             x /= f;
  23.         }
  24.  
  25.         if (p)
  26.         {
  27.             e[n].f = f;
  28.             e[n].put = p;
  29.             n++;
  30.         }
  31.         f++;
  32.     }
  33.  
  34.     for (int i = 0; i < n; i++)
  35.         cout << "factoru " << e[i].f << " la puterea " << e[i].put << endl;
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement