My favorites
▼
|
Sign in
nmcalc
projekt na inzynierie oprogramowania
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
2
attachment: bisekcja.cpp
(1.0 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <cstdlib>
#include <iostream>
using namespace std;
double abs(double x){
if(x < 0)
return x*(-1);
else
return x;
}
double f(double x)
{
//return(x * x + 2 * x);
//return(1-x*x);
return(x * x * x - 4 * x * x + 10);
}
double fr(double x, double y)
{
double f = x*x*x - 4*x*x + 10;
return f;
}
//=================================================================================
int main(int argc, char *argv[])
{
double b = 2;
double a = -3;
double wynik;
double x0 = 0;
double eps = 0.1;
double b1 = a;
double a1 = b;
if (x0==0) x0=0.5*(a+b);
if (f(a)*f(b)>0)
cout<< "blad!";
//abs(f(x0))>eps
int i =1;
while (abs(f(x0))>eps)
{
if (f(a)*f(x0)>0) a=x0;
else b=x0;
x0=0.5*(a+b);
}
wynik = x0;
cout<<"Miejsce zerowe lezy w przedziale: ("<< a<<"," << b <<")"<<endl;
// siecznych
system("PAUSE");
return EXIT_SUCCESS;
}
Powered by
Google Project Hosting