-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
55 lines (53 loc) · 1.23 KB
/
test.c
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
#include<stdio.h>
#include "polynomial.h"
void main()
{
int i;
double result;
const char * str ="2*2*-x*25-59+ 100x - 5514x^6 *- 10 * 10 +985.25 *x^23";
const char * str1 = "00002 x^009+ 51400*x^00006";
//const char str[30],str1[30];
//str="2*2*-x*25-59+ 100x - 5514x^6 *- 10 * 10 +985.25 *x^23";
//str1= "00002 x^009+ 51400*x^00006";
const char * str1_mul = "4x^6-2*x^3";
const char * str2_mul = "x-x^4*5";
polynomial a,b,c;
b = create_poly();
a = create_poly();
i = read_poly(a,str);
i = read_poly(b,str1);
if (i)
printf("\nRead success\n");
display_polynomial(a);
display_polynomial(b);
c = add_poly(a,b);
if(c){
printf("\nAddition successful!\n");
display_polynomial(c);
delete_poly(c);
}
c = subtract_poly(a,b);
if(c){
printf("\nSubtraction successful!\n");
display_polynomial(c);
delete_poly(c);
}
delete_poly(a);
delete_poly(b);
a = create_poly();
b = create_poly();
read_poly(a,str1_mul);
display_polynomial(a);
read_poly(b,str2_mul);
display_polynomial(b);
c = multiply_poly(a,b);
if(c){
printf("\nMultiplication successfull\n");
display_polynomial(c);
result = evaluate_poly(c,10.0);
printf("\nEvaluate with x=10 = %lf\n",result);
delete_poly(c);
}
delete_poly(a);
delete_poly(b);
}