Guest User

Untitled

a guest
Dec 3rd, 2019
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. float a,b,c,x1,x2,delta;
  10. ifstream f("date.in"); ofstream g("date.out");
  11. f>>a>>b>>c;
  12. if(a==0)g<<"ec.de gradul 1";
  13. else
  14. {
  15. delta=b*b-4*a*c;
  16. if(delta>0)
  17. {
  18. x1=(-b-sqrt(delta))/(2*a);
  19. x2=(-b+sqrt(delta))/(2*a);
  20. g<<"ec.are doua radacini reale";
  21. g<<"x1="<<x1<<"x2="<<x2;
  22. }
  23. else
  24. if(delta==0)
  25. {
  26. g<<"ec.are doua radacini reale";
  27. g<<"x1=x2="<<-b/(2*a);
  28. }
  29. else
  30. g<<"ec.are doua radacini reale";
  31. }
  32. f.close();g.close();
  33. }
  34.  
  35.  
  36.  
  37.  
  38. #include <iostream>
  39. #include<fstream>
  40.  
  41. using namespace std;
  42.  
  43. int main()
  44. { int a,b,r;
  45. ifstream f("euclid.in");
  46. ofstream g("euclid.out");
  47. f>>a>>b;
  48. while(a%b)
  49. {
  50. r=a%b;a=b;b=r;}
  51. g<<b;
  52. f.close();
  53. g.close();
  54.  
  55. }
  56.  
  57.  
  58.  
  59.  
  60. #include <iostream>
  61. #include <iostream>
  62. #include <math.h>
  63.  
  64. using namespace std;
  65.  
  66. int main()
  67. { unsigned int n,i,j,x,prim;
  68. cout<<"n=";cin>>n;
  69. for(i=1;i<=n;i++);
  70. {
  71. cout<<"numarul =");cin>>x;
  72. if(x==1) prim=0;
  73. else
  74. {
  75. prim=1; j=2;
  76. while(prim&&j<=sqrt(x))
  77. if(x%j= =0) prim =0;
  78. else j++;
  79. }
  80. if(prim)cout<<x<<endl;
  81. }
  82. }
  83.  
  84. #include <iostream>
  85.  
  86.  
  87. using namespace std;
  88.  
  89. int main()
  90. { unsigned int a, d, m;
  91. cout<<" a=";cin>>a;
  92. d=2;
  93. while(a>1)
  94. {
  95. m=0;
  96. while(a%m==0)
  97. {m++;a=a/d;}
  98. if(m)cout<<d<<"^"<<m<<"";
  99. d++;
  100. }
  101.  
  102.  
  103. }
  104.  
  105.  
  106.  
  107. #include <iostream>
  108. using namespace std;
  109.  
  110. int main()
  111. { int m, i, z, max, poz;
  112. cout<<"m=";cin>>m;
  113. randomize();
  114. max=rand()%122;poz=1;
  115. for(i=2;i<=m;i++)
  116. { z=rand()%122;
  117. if(z>max)
  118. {max=z; poz=i;}
  119.  
  120. }
  121. cout<<"maxim="<<max;
  122. cout<<"pe pozitia="<<poz;}
RAW Paste Data