alexon5519

8-programare

Nov 23rd, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<fstream.h>
  3. #include<math.h>
  4. int main(){
  5. ifstream f1("atestat.in");
  6. ofstream f2("atestat.out");
  7. int n,x,y,z,s,i=0,cmmdc,n1;
  8. f1>>n;
  9. n1=pow(10,6);
  10. x=n/n1;
  11. n1=pow(10,3);
  12. y=(n/n1)%n1;
  13. z=n%n1;
  14. f2<<x<<" "<<y<<" "<<z;
  15. i=x%y;
  16. while(i!=0){
  17. x=y;
  18. y=i;
  19. i=x%y;
  20. }
  21. cmmdc=y;
  22. s=cmmdc%z;
  23. while(s!=0){
  24. cmmdc=z;
  25. z=s;
  26. s=cmmdc%z;
  27. }
  28. f2<<endl<<z;
  29. f2.close();
  30. f1.close();
  31. }
Add Comment
Please, Sign In to add comment