Advertisement
catalyn

problema 4 -15.10.2014

Oct 15th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int numara(int x)
  5. {int cif,k=0,xx=x;
  6. while(x)
  7. {cif=xx%10;
  8. k++;
  9. x/=10;
  10. }
  11. return k;
  12. }
  13. int permuta(int k,int x)
  14.  
  15. {int p;
  16. p=pow(10,k-1);
  17. x=x/p+x%p*10;
  18. return x;
  19. }
  20. int nrprim(int x)
  21. {if(x==0 || x==1 || (x%2==0 && x!=2))
  22. return 0;
  23. for(i=3;i<=sqrt(x);i+=2)
  24. if(x%i==0)
  25. return 0;
  26. return 1;
  27. }
  28. int extraprim(int x)
  29. {int k=numara(x),i;
  30. for(i=1;i<=k;i++)
  31. {if(nrprim(x)==0)
  32. return 0;
  33. x=rotire(x,k)
  34. return 1;
  35.  
  36.  
  37.  
  38. int main()
  39. { int x;
  40. cout<<"x=";cin>>x;
  41. if(extraprim(x)==1)
  42. cout<<"da";
  43. else
  44. cout<<"nu";
  45. return 0;}
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement