Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<string>
- using namespace std;
- double x2(double x)
- {
- return x * x;
- }
- void zapiszFun(double (*f)(double x), double a, double b, int n, string nazwaPliku)
- {
- double odleglosc = (b - a) / n;
- fstream plik;
- plik.open(nazwaPliku, ios::out);
- if (plik.is_open())
- {
- for (int i = 0; a+i <= b; i += odleglosc)
- {
- plik << a + i << "\t" << f(a + i) << endl;
- }
- }
- plik.close();
- }
- //n-liczba czesci na ktora dzielimy przedzial [a,b]
- int main()
- {
- zapiszFun(x2, -1, 3, 4, "plik.txt");
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement