Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float f(float x)
- {
- return 2*x-5;
- }
- void wypelnij(int*n,float *t)
- {
- int x,dx;
- cout<<"Okresl ilosc elementow: ";
- cin>>*n;
- dx=(6+2)/(*n-1);
- for (int i=0;i<(*n);i++)
- {
- x=-2+i*dx;
- t[i]=f(x);
- }
- }
- void wypisz(int*n,float*t)
- {
- //cout<<*n;
- for (int i=0;i<*n;i++)
- {
- cout<<"Dla x= "<<i-2<<" funkcja 2x-5= "<<t[i]<<endl;
- }
- }
- int main()
- {
- int n;
- float t[20];
- wypelnij(&n,t);
- wypisz(&n,t);
- }
Advertisement
Add Comment
Please, Sign In to add comment