C语言FOR语句已经定义了变量。为什么还提示未声明?

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
int number;
for (int i=0;i<9;i++);
{

for (int j=0;j<9;j++);
{
number=i*10+j;
cout<<number<<"";

}
cout<<endl;

}
return 0;
}
这个位置的i 和j提示未定义标识符

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
int number;
for (int i=0;i<9;i++);//这里的分号要去掉,否则是一个空循环
{

for (int j=0;j<9;j++);//这里的分号要去掉,否则是一个空循环
{
number=i*10+j;
cout<<number<<"";

}
cout<<endl;

}
return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-06-17
把定义的变量拿到外面试试
for ()没有分号
int main()
{
int number;
int i,j;
for (i=0;i<9;i++)
{

for ( j=0;j<9;j++)
{
number=i*10+j;
cout<<number<<"";

}
cout<<endl;

}
return 0;
}
你用的是VC吧 VC6.0好像不能在for循环里定义变量本回答被网友采纳
第2个回答  2014-06-17
你的两个for语句后面多了个分号
可能是这个原因