"Topic link"
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
Submit Code:
#include <stdio.h>intMainvoid){ intcoefficient; intexponent; intCNT =1; while(SCANF ("%d%d", &coefficient, &exponent)! =EOF) { if(Exponent! =0&& coefficient! =0) {printf (CNT==1?"%d%d":"%d%d", coefficient * exponent, exponent-1); CNT=0; } } //if the derivative is 0 to output "0 0", feel good deceptive ... if(CNT = =1) printf ("0 0"); return 0;}
PAT (Basic level) practise:1010. Derivation of one-element polynomial