Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double f(double x)
- {
- return -(x*x)/50;
- }
- double g(double x)
- {
- return 1+(x*x)/100-x/200;
- }
- double pole(double c,int ile)
- {
- double x;
- double p=0;
- double dlugosc=c/ile;
- for(int i=0; i<ile;i++)
- {
- x=(dlugosc*i)+(dlugosc/2);
- p=p+dlugosc*fabs(g(x)-(f(x)));
- }
- return p;
- }
- double prostokat(int c){
- int x=0;
- for(int i=0;i<c;i++){
- if(fabs(f(i))>=26){
- x = i;
- break;
- }
- }
- return x;
- }
- int main()
- {
- int ile;
- double c;
- cout<<"Podaj C (ograniczenie przedziału z prawej strony): ";
- cin>>c;
- cout<<"Na ile przedzialow podzielic wyjsciowy przedzial: ";
- cin>>ile;
- // cout<<"wartosc pola to: "<<pole(c,ile)<<endl;
- double liczba = prostokat(c);
- double a = fabs(ceil(f(liczba)))-fabs(f(liczba));
- if(c < liczba+a+100){
- cout<<"c musi byc wieksze od "<<ceil(liczba+a+100);
- return 0;
- }
- cout<<endl<<"1. "<<"("<<liczba<<" , "<<"0"<<")";
- cout<<endl<<"2. "<<"("<<liczba<<" , "<<ceil(f(liczba))<<")";
- cout<<endl<<"3. "<<"("<<liczba+100<<" , "<<"0"<<")";
- cout<<endl<<"4. "<<"("<<liczba+100<<" , "<<ceil(f(liczba))<<")";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement