Home > Back-end >  C, two unary polynomial addition, look at the following code where is wrong
C, two unary polynomial addition, look at the following code where is wrong

Time:10-03

# include
Static int num=0;
Void the create (int array [100])
{num++;
Int moudulus, index, times=1;
Do {
Printf (" please enter the first item of the first % d % d a polynomial coefficient and index (enter "0, 0" to end the polynomial inputs) : \ n ", num, times);
Scanf_s (" % d, % d ", & amp; Moudulus, & amp; The index);
If (moudulus==0 & amp; & The index==0) break;
Array [index]=moudulus; Times++; } while (times & lt; 100); }
Void plus (int a [], int [] b, int result [])
{int I;
For (I=0; I & lt; 100; I++)
{result [I]=[I] a [I] + b; }}
Void print (int array [])
{int I;
Printf (" % d polynomial addition results for: \ n ", num);
For (I=99; I & gt; 0; I -)
{if (array [I]==0) continue;
If (array [I] <0) printf (" - ");
I==0? Printf (" % d ", array [I]) : printf (" % dx ^ % d ", array [I], I); }}
Int main () {
Int a [100]={0}, [100] b={0}, the result [100]={0}; Create (a);
Create (b);
Plus (a, b, result);
Print (result);
return 0; }

CodePudding user response:

This will compile, but run very strange