###### tags: `code`
# c14086028-homework-6-1
```cpp=
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define n 2
int valuefind(int ,int*, int*, int*);
int main(){
/* use the array to display the polynomial*/
int a[N] = {0};
int b[n] = {0};
int c[N] = {0};
int d=0;
char e = 'x';
int f = 0;
printf("input max power of f(x) ( max < %d \n",N);
scanf_s("%d", &d);
if (d <= N) {
for (int i = 0; i < N; i++) {
if (i < d) {
printf("innput the coefficient of x^ %d of f(x)\n", i);
scanf_s("%d", &a[i]);
continue;
}
if (i == d) {
f = i;
printf("innput the coefficient of x^ %d of f(x)\n", i);
scanf_s("%d", &a[i]);
break;
}
}
}
else {
printf("it is not valid number\n");
}
printf("innput the coefficient of x^0 of g(x)\n");
b[1] = 1;
scanf_s("%d", &b[0]);
valuefind(f,a, b, c);
/*print resual*/
printf("the resual is\n");
printf("f(x)=");
for (int i = f ; i >= 0; i--) {
printf("(%d)%c^%d", a[i], e, i);
if (i != 0) {
printf("+");
}
}
printf("\n");
printf("=");
printf("(\t");
for (int i = f ; i > 0; i--) {
printf("(%d)%c^%d", c[i], e, i - 1);
if (i != 1) {
printf("+");
}
}
printf("\t)");
printf("(\t");
for (int i = n - 1; i >= 0; i--) {
printf("(%d)%c^%d", b[i], e, i);
if (i != 0) {
printf("+");
}
}
printf("\t)");
printf("+");
printf("%d", c[0]);
system("pause\n");
return 0;
}
int valuefind(int f,int a[], int b[], int c[]) {
c[f] = a[f];
for (int i = f; i > 0; i--) {
c[i - 1] = a[i-1] + c[i] * -b[0];
}
return 0;
}
```