Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<fstream.h>
- int main(){
- ifstream f1("numere.in"); //i-divizorul
- ofstream f2("rezultate.out"); //d-de cate ori apare divizorul
- int x,i,d=0,y,j=1,e=0; //j-contor doar pentru prima valoare
- while(f1>>x){
- y=x;
- i=2;
- while(y>1){
- if(y%i==0){
- d++;
- y=y/i;}
- else{
- if(j==1){
- if(d>0)
- f2<<i<<" "<<d<<endl;
- if(y==1)
- j=2;}
- i++;
- d=0;}}
- if(x==i){
- e=x;
- break;}}
- if(e==0)
- cout<<"NU EXISTA";
- else
- cout<<e;
- f2.close();
- f1.close();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement