Advertisement
alexon5519

5-programare

Oct 29th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<fstream.h>
  3. int main(){
  4. ifstream f1("numere.in"); //i-divizorul
  5. ofstream f2("rezultate.out"); //d-de cate ori apare divizorul
  6. int x,i,d=0,y,j=1,e=0; //j-contor doar pentru prima valoare
  7. while(f1>>x){
  8. y=x;
  9. i=2;
  10. while(y>1){
  11. if(y%i==0){
  12. d++;
  13. y=y/i;}
  14. else{
  15. if(j==1){
  16. if(d>0)
  17. f2<<i<<" "<<d<<endl;
  18. if(y==1)
  19. j=2;}
  20. i++;
  21. d=0;}}
  22. if(x==i){
  23. e=x;
  24. break;}}
  25. if(e==0)
  26. cout<<"NU EXISTA";
  27. else
  28. cout<<e;
  29. f2.close();
  30. f1.close();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement