quof,exp和var正在返回无意义的内容我做错了什么? 我也需要一个函数来推导出多项式
#include <stdio.h>
#include <math.h>
#include <ctype.h>
int main()
{
char poly[50];
int quof[10];
int exp[10];
int contquof=0, contexp=0, contvar=0, i=0;
char var[6];
printf("Introduza o polinómio\n");
scanf("%s", &poly);
for(i=0; poly[i]!='\0'; i++)
{
if(isalpha(poly[i-1]) && isdigit(poly[i]))
{
exp[contexp]=poly[i];
contexp++;
}
if(isdigit(poly[i]))
{
quof[contquof]=poly[i];
contquof++;
}
if(isalpha(poly[i]))
{
var[contvar]=poly[i];
contvar++;
}
for(i=0; i<2; i++)
{
printf("%d\n", quof[i]);
printf("%d\n", exp[i]);
printf("%d\n", var[i]);
}
return 0;
}
}
输入的一个例子:2x⁴+ 3y所以值应该存储,如2,3 - &gt; quof [0],[1] x,y - &gt; var [0],var [1] 4 - &gt; EXP [0]