C++初学有点问题

来源:百度知道 编辑:UC知道 时间:2024/09/24 11:31:01
oid jsVal()
{
int i,j,thou,hun,ten,data;
int a,b;
for(i=0;i<200;i++)
{ thou=a[i]/1000;
hun=a[i]%1000/100;
ten=a[i]%100/10;
data=a[i]%10;
if(hun==0 || data==0)
{
a=data*10+thou;
b=hun*10+ten;
}
if((a-b)%2!=0 && a*b%17==0)
{
b[cnt]=a[i];
cnt++;
}
}
for(i=0;i<cnt-1;i++)
for(j=i+1;j<cnt;j++)
if(b[i]<b[j])
{
data=b[i];
b[i]=b[j];
b[j]=data;
}

}
为什么我一直组建不成功啊?它就是说有一个错误~
C:\Wexam\35010001\prog.c(20) : error C2109: subscript requires array or pointer type
C:\Wexam\35010001\prog.c(20) : error C2106: '=' : left operand must be l-value
C:\Wexam\35010001\prog.c(26) : error C2109: subscript requires array or pointer type
C:\Wexam\35010001\prog.c(26) : error C2109: subscript re

int a,b;

改为

int a[200],b[200];

什么错误没说?
用的那个编译器软件和版本没说?

是编译错误,还是程序中有个错误也没说。

程序错误的话,好歹给个行号,懒得看啊。

是不是没有主函数呀
void main()
{
jsVal();
}

b不是数组!

int a[200],b[200],定义成数组,你那是变量
a,b用x,y替换