Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7. //--------------------------------------------
  8. double Rezultatas(int a, int b, int c, int d);
  9. double Didziausias(double didz);
  10. string Zinute(int c, int d);
  11. //--------------------------------------------
  12. int main(){
  13. int n,a,b,c,d;                                                  //++
  14.     ifstream sfd("Argumentai.txt");
  15.     ofstream rfd("Rezultatai.txt");
  16.     sfd >> n;
  17.  
  18.         for(int x = 0; x < n; x++){
  19.             sfd >> a >> b >> c >> d;
  20.             //Jai klaida yra
  21.             if(Zinute(c,d).length() != 0){
  22.                 cout << Zinute(c,d) << endl;
  23.                 double Rezultata = 0;
  24.                 //Pabaiga
  25.                 if(x == n-1){
  26.                     double s = Didziausias(Rezultata);
  27.                     cout << "Didžiausia funkcijos reikšmė: " << fixed << setprecision(2) << s << endl;
  28.                 }
  29.             }
  30.             //Jai klaidos nera
  31.             if(Zinute(c,d).length() == 0){
  32.                 double Rezultata = Rezultatas(a,b,c,d);
  33.                 double s = Didziausias(Rezultata);
  34.                 cout << fixed << setprecision(2) << Rezultata << endl;    //+
  35.  
  36.                 //Pabaiga
  37.                 if(x == n-1){
  38.                     cout << "Didžiausia funkcijos reikšmė: " << s << endl;
  39.                 }
  40.             }
  41.         }
  42.  
  43.     sfd.close();
  44.     rfd.close();
  45.     return 0;
  46. }
  47. //--------------------------------------------
  48. double Rezultatas(int a, int b, int c, int d)
  49. {
  50.     return (a+b)/(pow(-c,2)) + d*0.5;                           //?
  51. }
  52. //--------------------------------------------
  53. double Didziausias(double didz){
  54.  
  55.             double d = didz;
  56.             if(didz >= d)
  57.                 d = didz;
  58.             return d;
  59. }
  60. //--------------------------------------------
  61. string Zinute(int c, int d){                                    //+
  62.         if(c == 0){
  63.             return "KLAIDA! c negali bûti lygus nuliui!";
  64.         }if(d < 0){
  65.             return "KLAIDA! d negali bûti neigiamas!";
  66.         }else{return "";}
  67. }
  68. //--------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement