谁能告诉我哪里错了?

来源:百度知道 编辑:UC知道 时间:2024/06/06 07:48:21
void jsValue()
{int i,j,t,q,b,s,g;
for(i=0;i<300;i++)
{
q=a[i]/1000;b=(a[i]%1000)/100;s=(a[i]%100)/10;g=a[i]%10;
if(q+b==s+g) b[cnt++]=a[i];
}
for(j=cnt;j>0;j--)
{
for(i=0;i<j;i++)
{
if(b[i]<b[i+1])
{t=b[i];b[i]=b[i+1];b[i+1]=t;}
}
}
}

prog.c(8) : error C2109: subscript requires array or pointer type
prog.c(8) : error C2106: '=' : left operand must be l-value
prog.c(14) : error C2109: subscript requires array or pointer type
prog.c(14) : error C2109: subscript requires array or pointer type
prog.c(15) : error C2109: subscript requires array or pointer type
prog.c(15) : error C2109: subscript requires array or pointer type
prog.c(15) : error C2109: subscript requires array or pointer type
prog.c(15) : error C2106: '=' : left operand must be l-value
prog.c(15) : error C2109: subscript requires array or pointer

你的b定义错了

程序里是这样定义b的:int b;
而却是这样使用b:b[i+1]

这样肯定是错的啦

b[cnt++]=a[i];

if(b[i]<b[i+1])
{t=b[i];b[i]=b[i+1];b[i+1]=t;}

b 不是数组,怎么可以这样用?

怎么不缩进,读着真费劲