Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GYAK8-ból a 6os
- // Írjunk algoritmust a másodfokú egyenlet megoldására!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int a,b,c,d;
- cin>>a;
- cin>>b;
- cin>>c;
- if (a==0)
- cout<<"Az egyenlet nem masodfoku."<<endl;
- else
- d=b*b-4*a*c;
- if (d>0)
- {
- cout<<(-b+sqrt(d))/(2*a)<<endl;
- cout<<(-b-sqrt(d))/(2*a);
- }
- if (d==0)
- {
- cout<<(-b)/(2*a);
- }
- if (d<0)
- {
- cout<<"Nincs valos megoldas."<<endl;
- }
- return 0;
- }
- ======================================================================================================================================
- //GYAK8-ból az 5ös
- // Határozzuk meg a 2x szám utolsó számjegyét, ahol x egy adott természetes szám!
- #include <iostream>
- using namespace std;
- int main()
- {
- int x;
- cout<<"Ird be 2-nek a hatvanykitevojet:";cin>>x;
- if (x==0)
- cout<<"Utolso szamjegy:1";
- else
- if (x%4==1)
- cout<<"Utolso szamjegy:2";
- else
- if (x%4==2)
- cout<<"Utolso szamjegy:4";
- else
- if (x%4==3)
- cout<<"Utolso szamjegy:3";
- else
- cout<<"Utolso szamjegy:6";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement