daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Dec 17th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<cmath>
  3. #include<fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char** argv){
  8.     ifstream f;
  9.     f.open("plik1.txt");
  10.     while(!f.eof()){
  11.        
  12.     int a,b,c;
  13.     float x1,x2;
  14.  
  15.       cout<<"Rownanie kwadratowe" <<endl;
  16.       f>>a;
  17.       cout<<"wspoczynnik a: " <<a<<endl;
  18.       f>>b;
  19.       cout<<"wspoczynnik b: "<<b<<endl;
  20.        f>>c;
  21.       cout<<"wspoczynnik c: "<<c<<endl;
  22.      
  23.     float delta=b*b-(4*a*c);
  24.     if(delta<0){
  25.       cout<<"Brak rozwiazan rownania"<<endl;
  26. }else if(delta == 0){
  27.       x1 = -b/(2*a);
  28.       cout<<"Jendo rozwiazanie rownania: "<<x1<<endl;
  29. }else if(delta >0){
  30.       x1 = -b + sqrt(delta)/(2*a);
  31.       x2 = -b - sqrt(delta)/(2*a);
  32.       cout<<"Dwa rozwiazania: "<<endl;
  33.       cout<<x1<<endl;
  34.       cout<<x2<<endl;
  35.      
  36.  
  37. }
  38. f.close();
  39. ofstream f1("plik2.txt");
  40. //f1.open("plik2.txt");
  41. f1<< x1 << x2 <<endl;
  42. f1.close();
  43.  
  44.  
  45.  
  46.    
  47.    
  48.    
  49.     }
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top