Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <conio.h>
- #include <fstream>
- using namespace std;
- void kwadratowa (float a,float b,float c)
- {
- float delta=(b*b)-(4*a*c);
- if (delta<0)
- cout<<"nie ma miejsc zerowych"<<endl;
- if (delta==0)
- {
- float x1=(-b)/(2*a);
- cout<<"miejsce zerowe wynosi "<<x1<<endl;
- }
- if (delta>0)
- {
- float x1=(-b-sqrt(delta))/(2*a);
- float x2=(-b+sqrt(delta))/(2*a);
- cout<<"miejsca zerowe to "<<x1<<" oraz "<<x2<<endl;
- }
- }
- main ()
- {
- ifstream odczyt("rownanie kwadratowe z pliku dane.txt");
- float a,b,c;
- if (odczyt)
- {
- while (!odczyt.eof())
- {
- odczyt>>a;
- odczyt>>b;
- odczyt>>c;
- kwadratowa(a,b,c);
- }
- }
- fstream plik("rownanie kwadratowe z pliku wynik.txt", ios::out);
- if( plik.good() )
- {
- plik <<"miejsca zerowe to: "<< kwadratowa << " ";
- plik.flush();
- plik.close();
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement