The design function is to find the derivative of the polynomial of one element. (Note: The first-order derivative of xn (n is an integer) is n*xn-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
Sample output:
12 3-10 1) 6 0
You can enter two processing of two. The biggest flaw in thinking may lie in the existence of an input that results in an output of "0 0", such as 2 0
#include <bits/stdc++.h>using namespacestd;intCOF, num;intMain () {BOOLFlag =true; BOOLVis =false; while(SCANF ("%d%d", &num, &COF)! =EOF) { if(flag) {if(NUM*COF! =0) {printf ("%d%d", NUM*COF, cof-1); Flag=false; Vis=true; } } Else{ if(NUM*COF! =0) {printf ("%d%d", NUM*COF, cof-1); Vis=true; } } } if(!Vis) {printf ("0 0"); } return 0;}
Capouis ' CODE
pat-basic-1010-the derivation of one-element polynomial