/*1010. Derivation of one-element polynomial (25) the derivative of the polynomial is obtained by the design function. (Note: The first-order derivative of X^n (n is an integer) is n*x^n-1. Input format: input polynomial non-0 coefficients and exponents in exponential degradation (absolute values are integers not exceeding 1000). The numbers are separated by a space. Output format: Outputs the coefficients and exponents of the derivative polynomial not 0 in the same format as the input. The numbers are separated by a space, but cannot have extra spaces at the end. Note that the exponent and coefficients for the "0 polynomial" are 0, but are expressed as "0 0". Input Sample: 3 4-5 2 6 1-2 0 Output Sample: 12 3-10 1 6 0*//* idea 1: Structure-assisted Thinking 2: Edge input edge processing while (cin>>x>> Y) {...}, resolve the length and end of unknown problem */#include <iostream> #include <vector>using namespace Std;int main () {int a A, B; BOOL First=true; while (cin>>a>>b) {if (a!=0&&b!=0) {if (!first) {//Not to last item (0-item) COUT<&L t; " "; } cout<<a*b<< "" <<b-1; First = false; }} if (first) {cout<< "0 0"; } return 0;} /*↓ Ideas 2 Source code 15/20 (existence bug:0 0 use cases) *//*1010. Derivation of one-element polynomial (25) the derivative of the polynomial is obtained by the design function. (Note: The first-order derivative of X^n (n is an integer) is n*x^n-1. Input format: input polynomial non-0 coefficients and exponents in exponential degradation (absolute values are integers not exceeding 1000). The numbers are separated by a space. Output format: Outputs the coefficients and exponents of the derivative polynomial not 0 in the same format as the input. The numbers are separated by a space, but cannot have extra spaces at the end. Note that the exponent and coefficients for the "0 polynomial" are 0, but are expressed as "0 0".Input Sample: 3 4-5 2 6 1-2 0 Output Example: 3-10 1 6 0*///#include <iostream>//#include <vector>//using namespace std ;////struct item{//int factor;//coefficient//int index;//int derivative_factor;//derivative factor//int derivative_index;//derivative index/ /};////int Main () {//Vector<item>::iterator iter;//vector<item> func_items;//function polynomial////item tmp;// Tmp.index = -1;//for (; Tmp.index! = 0;) {//scanf ("%d", &tmp.factor);//scanf ("%d", &tmp.index); if (tmp.index!=0) {//Tmp.derivative_factor = tmp.factor*tmp.index;//Tmp.derivative_index = tmp.index-1;//Func_items.push_back (TMP);//}//}//////print//;//for (int i=0,size = Fu Nc_items.size (); i<size;i++)//printf ("%d%d%s", Func_items[i].derivative_factor, Func_items[i].derivative_index , i!=size-1? " ":");//////printf ("*");//test//return 0;//}
C++ Pat B 1010. Derivation of one-dimensional polynomial (25/25)