Advertisement
Eddie_1337

5 atestat

Nov 1st, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream f("Numere.in");
  7. ofstream g("Rezultate.out");
  8.  
  9. void descompunere(int x) {
  10.     int d = 2, p;
  11.     while (x > 1) {
  12.         p = 0;
  13.         while (!(x % d)) {
  14.             p++;
  15.             x /= d;
  16.         }
  17.         if (p)
  18.             g << d << ' ' << p << endl;
  19.         d++;
  20.     }
  21. }
  22.  
  23. int main() {
  24.     int y, x; bool q;
  25.     f >> y;
  26.     while (f >> x) {
  27.         q = 1;
  28.         for (int i = 2; q; i++)
  29.             if (!(x % i))
  30.                 q = 0;
  31.         if (!q)
  32.             break;
  33.     }
  34.     cout << x;
  35.     descompunere(y);
  36.     cout << endl;
  37.     system("pause");
  38.     f.close();
  39.     g.close();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement