add test poly
parent
2590a383e1
commit
89f0f2e1c5
|
@ -16,6 +16,31 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test6() {
|
||||||
|
printf("TEST 6: MUL POLY AND UINT\n");
|
||||||
|
// (-6x^4+3x+1)*10 = -60x^4+30x^1+10
|
||||||
|
|
||||||
|
Polynomial p1, p2;
|
||||||
|
init_polynomial(&p1);
|
||||||
|
add_term(&p1, 1, 0);
|
||||||
|
add_term(&p1, -6, 4);
|
||||||
|
add_term(&p1, 3, 1);
|
||||||
|
// Целое число так же представляю в виде полинома
|
||||||
|
init_polynomial(&p2);
|
||||||
|
add_term(&p2, 10, 0);
|
||||||
|
Polynomial res = mul_polynomials(&p1, &p2);
|
||||||
|
sort_polynomial(&res);
|
||||||
|
|
||||||
|
printf("EXPECTED:\n-60x^4+30x^1+10\n");
|
||||||
|
printf("OUTPUT:\n");
|
||||||
|
print_polynomial(&res);
|
||||||
|
|
||||||
|
free_polynomial(&p1);
|
||||||
|
free_polynomial(&p2);
|
||||||
|
free_polynomial(&res);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void test5() {
|
void test5() {
|
||||||
printf("TEST 5: UINT DEGREE\n");
|
printf("TEST 5: UINT DEGREE\n");
|
||||||
// (-6x^4+3x+1)^5 = -7776x^20+19440x^17+6480x^16-19440x^14-12960x^13-2160x^12+9720x^11+9720x^10+3240x^9-2070x^8-3240x^7-1620x^6-117x^5+375x^4+270x^3+90x^2+15x^1+1
|
// (-6x^4+3x+1)^5 = -7776x^20+19440x^17+6480x^16-19440x^14-12960x^13-2160x^12+9720x^11+9720x^10+3240x^9-2070x^8-3240x^7-1620x^6-117x^5+375x^4+270x^3+90x^2+15x^1+1
|
||||||
|
@ -141,5 +166,6 @@ void tests() {
|
||||||
test2(); printf("\n\n");
|
test2(); printf("\n\n");
|
||||||
test3(); printf("\n\n");
|
test3(); printf("\n\n");
|
||||||
test4(); printf("\n\n");
|
test4(); printf("\n\n");
|
||||||
test5();
|
test5(); printf("\n\n");
|
||||||
|
test6();
|
||||||
}
|
}
|
Loading…
Reference in New Issue