
1 #include<stdio.h> 2 #include<math.h> 3 #include<stdlib.h> 4 typedef struct{ 5 int coef; 6 int exp; 7 }PolyTerm; 8 typedef struct{ 9 PolyTerm *element; 10 int length; 11 }SeqPoly; 12 Create(SeqPoly*P) 13 { 14 scanf("%d",&P->length); 15 P->element=(PolyTerm*)malloc((P->length+1)*sizeof(PolyTerm)); 16 for(int i=1;i<=P->length;i++) 17 { 18 scanf("%d",&P->element[i].coef); 19 scanf("%d",&P->element[i].exp); 20 } 21 } 22 Get(SeqPoly*P) 23 { 24 25 int i,t=1; 26 for(i=1;i<=P->length;i++) 27 { 28 P->element[i].coef=P->element[i].coef*P->element[i].exp; 29 P->element[i].exp=P->element[i].exp-1; 30 } 31 while(P->element[t].exp<-1)t++; 32 if(P->element[t].exp==-1) 33 { 34 P->length-=1; 35 for(i=t;i<=P->length;i++) 36 P->element[i]=P->element[i+1]; 37 } 38 39 } 40 Order(SeqPoly*P) 41 { 42 for(int i=1;i<=P->length;i++) 43 { 44 printf("第%d项%dx^%d\n",i,P->element[i].coef,P->element[i].exp); 45 } 46 } 47 int main() 48 { 49 SeqPoly P; 50 Create(&P); 51 Get(&P); 52 Order(&P); 53 return 0; 54 55 }