Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- //--------------------------------------------
- double Rezultatas(int a, int b, int c, int d);
- double Didziausias(double didz);
- string Zinute(int c, int d);
- //--------------------------------------------
- int main(){
- int n,a,b,c,d; //++
- ifstream sfd("Argumentai.txt");
- ofstream rfd("Rezultatai.txt");
- sfd >> n;
- for(int x = 0; x < n; x++){
- sfd >> a >> b >> c >> d;
- //Jai klaida yra
- if(Zinute(c,d).length() != 0){
- cout << Zinute(c,d) << endl;
- double Rezultata = 0;
- //Pabaiga
- if(x == n-1){
- double s = Didziausias(Rezultata);
- cout << "Didžiausia funkcijos reikšmė: " << fixed << setprecision(2) << s << endl;
- }
- }
- //Jai klaidos nera
- if(Zinute(c,d).length() == 0){
- double Rezultata = Rezultatas(a,b,c,d);
- double s = Didziausias(Rezultata);
- cout << fixed << setprecision(2) << Rezultata << endl; //+
- //Pabaiga
- if(x == n-1){
- cout << "Didžiausia funkcijos reikšmė: " << s << endl;
- }
- }
- }
- sfd.close();
- rfd.close();
- return 0;
- }
- //--------------------------------------------
- double Rezultatas(int a, int b, int c, int d)
- {
- return (a+b)/(pow(-c,2)) + d*0.5; //?
- }
- //--------------------------------------------
- double Didziausias(double didz){
- double d = didz;
- if(didz >= d)
- d = didz;
- return d;
- }
- //--------------------------------------------
- string Zinute(int c, int d){ //+
- if(c == 0){
- return "KLAIDA! c negali bûti lygus nuliui!";
- }if(d < 0){
- return "KLAIDA! d negali bûti neigiamas!";
- }else{return "";}
- }
- //--------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement