Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Utwórz strukturę o nazwie fun_lin z dwoma polami a oraz b(parametry funkcji liniowej y=ax+b). Napisz trzy
- funkcje: wpr– funkcja służąca do wprowadzenia a i b zwracająca strukturę; zero– funkcja jako argument
- przyjmuje strukturę i zwraca miejsce zerowe funkcji (zakładamy że a!=0); wart– funkcja zwracająca wartość
- funkcji w punkcie przesłanym do funkcji jako drugi argument. W funkcji mainutwórz stworzoną strukturę i
- napisz wywołania funkcji.
- #include "stdafx.h"
- #include <cmath>
- #include <cstdlib>
- #include <cstdio>
- #include <iostream>
- using namespace std;
- struct fun_lin
- {
- double a,b;
- };
- fun_lin wpr()
- {
- fun_lin jeden;
- cout<<"podaj a : ";
- cin>>jeden.a;
- cout<<"podaj b : ";
- cin>>jeden.b;
- return jeden;
- }
- double zero(fun_lin jeden)
- {
- return -(jeden.b/jeden.a);
- }
- double wart(fun_lin jeden, double x)
- {
- return jeden.a*x+jeden.b;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- fun_lin jeden;
- double x;
- jeden=wpr();
- cout<<"miejsce zerowe : "<<zero(jeden)<<endl;
- cout<<"podaj x : ";
- cin>>x;
- cout<<"wartosc funkcji w punkcie "<<x<<" wynosi : "<<wart(jeden,x)<<endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment