Dokończ przerabianie kodu aby cykalo w C++... Prosze fast :D
#include <iostream>;
using namespace std ;
int main()
{
cout<<"rownanie kwadratowe "<< endl;
cout <<"podaj wartosc a "<<endl;
cin>> a;
cout <<"podaj wartosc b" <<endl;
cin>>b;
cout <<"podaj wartosc c" <<endl;
cin>>c;
delta:=b*b-4*a*c;
if (delta== 0);
}
{cout<<"delta=0 wiec rownanie ma jedno rozwiazanie"<<endl;
cout <<"delta<0 wiec niema piergwiastkow"<<endl;
x1=(-b+sqrt(delta))/2*a;
x2=(-b-sqrt(delta))/2*a;
cout << "Pierwiastek x1: " << x1 <<", pierwiastek x2: " << x2;
}
return 0 ;
}
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
Proszę:
#include <iostream>
#include <cmath>
using namespace std ;
int main(int argc, char *argv[]) {
float a,b,c;
cout << "rownanie kwadratowe " << endl;
cout << "podaj wartosc a " << endl;
cin >> a;
cout << "podaj wartosc b" << endl;
cin >> b;
cout << "podaj wartosc c" << endl;
cin >> c;
float delta = b*b - 4*a*c;
if (delta == 0.0f) {
cout << "delta = 0, wiec rownanie ma jedno rozwiazanie" << endl;
float x1=(-b+sqrtf(delta))/2*a;
cout << "Pierwiastek x1: " << x1 << endl;
return 0;
} else if(delta < 0.0f) {
cout << "delta < 0, wiec nie ma pierwiastkow" << endl;
return 0;
} else {
float x1=(-b+sqrtf(delta))/2*a;
float x2=(-b-sqrtf(delta))/2*a;
cout << "Pierwiastek x1: " << x1 <<"\nPierwiastek x2: " << x2 << endl;
return 0;
}
}