Write a function to add two polynomials. Do not destroy the input. Use a linked list implementation
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Write a function to add two polynomials. Do not destroy the input. Use a linked list implementation相关的知识,希望对你有一定的参考价值。
Write a function to add two polynomials. Do not destroy the input. Use a
linked list implementation. If the polynomials have M and N terms, respectively,
what is the time complexity of your program?
Input Specification:
1. All the coefficients of polynomials are integers;
2. The coefficients and exponents of each polynomial is stored in increasing order of
exponents to a file, e.g. the following file
4,2
2,3
1,5
represents the polynomial x^5+2x^3+4x^2;
3. To read the file including coefficients and exponents, the filename as the
parameter is presented when the program is executed as the following figure:
where “HW1” is the program name (when the source code is submitted to me in
an email as the attached file, the filename must be “HW1_Student ID.c”, e.g.
HW1_0902200102.c), “polya.txt” and “polyb.txt” are the names of files including
coefficients and exponents of two polynomials, and the file “polyc.txt” is used to
store the sum.
4. To implement the function that the filename is provided as the program
parameter, we may use the following code:
#include <stdio.h>
/* All the program parameters, as the strings, are stored in
argv[], and argv[0] is the name of program. */
int main(int argc, char *argv[])
FILE * file;
file = fopen(argv[1], “r”);
……
fclose(file);
return 0;
以上是关于Write a function to add two polynomials. Do not destroy the input. Use a linked list implementation的主要内容,如果未能解决你的问题,请参考以下文章
[Recompose] Add Local State to a Functional Stateless Component using Recompose
[Recompose] Add Lifecycle Hooks to a Functional Stateless Component using Recompose
编译安装mysql ERROR: 1 Can't create/write to file '/tmp/#sql_86b_0.MYI'
git GUI 中的 Git add (ctrl+A) 和 Stage to Commit (ctrl+T) 有啥区别?
Linux系统常见错误***error*** (zip#Write) sorry, your system doesn t appear to have the zip pgm
linux vi 报错 E37: No write since last change (add ! to override)