Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. //GYAK8-ból a 6os
  2. // Írjunk algoritmust a másodfokú egyenlet megoldására!
  3.  
  4. #include <iostream>
  5. #include <math.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. int a,b,c,d;
  12.  
  13. cin>>a;
  14. cin>>b;
  15. cin>>c;
  16.  
  17. if (a==0)
  18.  
  19. cout<<"Az egyenlet nem masodfoku."<<endl;
  20.  
  21. else
  22. d=b*b-4*a*c;
  23. if (d>0)
  24. {
  25. cout<<(-b+sqrt(d))/(2*a)<<endl;
  26. cout<<(-b-sqrt(d))/(2*a);
  27.  
  28. }
  29.  
  30. if (d==0)
  31. {
  32. cout<<(-b)/(2*a);
  33. }
  34.  
  35. if (d<0)
  36. {
  37. cout<<"Nincs valos megoldas."<<endl;
  38. }
  39.  
  40. return 0;
  41. }
  42.  
  43.  
  44. ======================================================================================================================================
  45. //GYAK8-ból az 5ös
  46. // Határozzuk meg a 2x szám utolsó számjegyét, ahol x egy adott természetes szám!
  47.  
  48. #include <iostream>
  49.  
  50. using namespace std;
  51.  
  52. int main()
  53. {
  54. int x;
  55.  
  56. cout<<"Ird be 2-nek a hatvanykitevojet:";cin>>x;
  57.  
  58. if (x==0)
  59.  
  60. cout<<"Utolso szamjegy:1";
  61.  
  62. else
  63. if (x%4==1)
  64.  
  65. cout<<"Utolso szamjegy:2";
  66.  
  67. else
  68. if (x%4==2)
  69.  
  70. cout<<"Utolso szamjegy:4";
  71.  
  72. else
  73. if (x%4==3)
  74.  
  75. cout<<"Utolso szamjegy:3";
  76.  
  77. else
  78.  
  79. cout<<"Utolso szamjegy:6";
  80.  
  81.  
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement