Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- double x;
- int wybor;
- bool petla = true;
- while( petla ){
- cout<<" Zamiana Jednostek\n";
- cout<<"1. Metry na milimetry\n";
- cout<<"2. Metry na centymetry\n";
- cout<<"3. Metry na decymetry\n";
- cout<<"4. By zakonczyc program\n";
- cin>>wybor;
- switch( wybor )
- {
- case 1:
- cout<<"Podaj ilosc metrow\n";
- cin>>x;
- cout<<x<<" metrow to "<<x*0.001<<" milimetrow.\n";
- break;
- case 2:
- cout<<"Podaj ilosc metrow\n";
- cin>>x;
- cout<<x<<" metrow to "<<x*0.01<<" centymetrow.\n";
- break;
- case 3:
- cout<<"Podaj ilosc metrow\n";
- cin>>x;
- cout<<x<<" metrow to "<<x*0.1<<" decymetrow.\n";
- break;
- case 4:
- petla = false;
- break;
- default:
- cout<<"Podano nieprawidlowa wartosc";
- break;
- }
- cout<<"\n";
- }
- return 0;
- }
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int a, b, c, x1, x2, delta = b*b-4*a*c;
- cout << "Podaj a: ";
- cin >> a;
- cout << "Podaj b: ";
- cin >> b;
- cout << "Podaj c: ";
- cin >> c;
- if(a==0)
- {
- cout<<"To nie jest rownanie kwadratowe";
- }
- else
- {
- if( delta > 0 )
- {
- x1=(-b-sqrt(delta))/(2*a);
- x2=(-b+sqrt(delta))/(2*a);
- cout<<"x1 = "<<x1<<"/n";
- cout<<"x2 = "<<x2;
- }
- else if(delta==0)
- {
- x1=-b/(2*a);
- cout<<"x0 = "<<x1;
- }
- else // delta < 0
- {
- cout<<"Brak rozwiazan";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement