fork(1) download
  1. #include <fstream>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. using namespace std;
  6.  
  7. float a=0,b=0,c=0;
  8.  
  9. float reading()
  10. {
  11. char A[64],B[64],C[64];
  12.  
  13. ifstream input("IN.txt");
  14. input.getline(A,sizeof(A));
  15. input.getline(B,sizeof(B));
  16. input.getline(C,sizeof(C));
  17. a=atof(A);
  18. b=atof(B);
  19. c=atof(C);
  20. return a,b,c;
  21. }
  22.  
  23. float calc(float a,float b, float c)
  24. {
  25. float D=(b*b - 4*a*c);
  26. cout<<"D = "<<D<<endl;
  27. if(D>0)
  28.  
  29. {
  30. cout<<"X1 = "<<((-b+sqrt(D))/(2*a))<<endl;
  31. cout<<"X2 = "<<((-b-sqrt(D))/(2*a))<<endl;
  32. }
  33. else if(D==0)
  34. {
  35. cout<<"X = "<<(-b/2*a);
  36. }
  37. else cout<<"no solutions";
  38. }
  39. int main()
  40. {
  41.  
  42. reading();
  43. cout<<"a="<<a<<endl<<"b="<<b<<endl<<"c="<<c<<endl;
  44. calc(a,b,c);
  45. getchar();
  46. return 0;
  47. }
Success #stdin #stdout 0s 3436KB
stdin
Standard input is empty
stdout
a=0
b=0
c=0
D = 0
X = -0