• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 18th, 2019 79 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 zakres(float a, float b,float c)
8. {
9.     int tablica[3];
10.     int delta=pow(b,2)-4*a*c;
11.     if(delta>0)
12.     {
13.         int x1=(-b-sqrt(delta))/(4*a);
14.         int x2=(-b+sqrt(delta))/(4*a);
15.         int p=(-b)/(2*a);
16.
17.         tablica[0]=x1-(2*(p-x1));   //zapisywanie granic do tablicy tablica[0] - lewa granica
18.         tablica[1]=p;               //tablica[1] - punkt p, wierzcholek paraboli
19.         tablica[2]=x2+(2*(x2-p));   //tablica[2] - prawa granica
20.     }
21.
22.     else if(delta==0)
23.     {
24.         int x0=(-b)/(2*a);
25.         tablica[0]=x0-5;
26.         tablica[1]=x0;
27.         tablica[2]=x0+5;
28.     }
29.     else
30.     {
31.         int p=(-b)/(2*a);
32.         tablica[0]=p-5;
33.         tablica[1]=p;
34.         tablica[2]=p+5;
35.     }
36.
37.     return tablica;
38. }
39.
40. }
41.
42.
43.
44.
45.
46.
47. int main()
48. {
49.     int a, b, c, n, x1;
50.     cout<< "Podaj a: ";     cin>>a;     cout<<endl;
51.     cout<< "Podaj b: ";     cin>>b;     cout<<endl;
52.     cout<< "Podaj c: ";     cin>>c;     cout<<endl;
53.
54.     cout<<"Ile ma być punktow pomiarowych funkcji?\n"<<endl;
55.     cin>>n;
56.     int delta=pow(b,2)-4*a*c;
57.     x1=(-b-sqrt(delta))/(4*a);
58.     x1=(-b-sqrt(delta))/(4*a);
59.     int wartosc1 = zakres(a,b,c);
60.
61.     cout<< "Wartosc %f", wartosc1[0];
62.     cout<< "Wartosc %f", wartosc1[1];
63.     cout<< "Wartosc %f", wartosc1[2];
64.
65.
66.     plik.open("wizytowka.txt",ios::out);
67.
68.     return 0;
69. }
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.

Top