请问error C2297: '<<' : illegal, right operand has type 'char [3]'
#include<iostream>usingnamespacestd;intmain(){inti,j,k,n=0;//用n记录个数for(i=1;i<=3;i++)f...
#include<iostream>
using namespacestd;
int main()
{
int i, j, k,n=0;
// 用n记录个数
for (i=1; i<=3; i++)
for (j=1; j<=3; j++)
for (k=0; k<=3; k++)
{
if (i!=j && j!=k && i!=k)
//判断i, j, k三位各不相同
{
cout<<i<<j<<k<<" ";
n++;
if (n%3 == 0)
cout<<endl;
}
}
cout<<endl;
cout<<"n="<<n<<endl;
return 0;
}
C:\Users\HP\Desktop\C++作业\4.cpp(2) : error C2873: 'namespacestd' : symbol cannot be used in a using-declaration
C:\Users\HP\Desktop\C++作业\4.cpp(14) : error C2065: 'cout' : undeclared identifier
C:\Users\HP\Desktop\C++作业\4.cpp(14) : error C2297: '<<' : illegal, right operand has type 'char [3]'
C:\Users\HP\Desktop\C++作业\4.cpp(17) : error C2065: 'endl' : undeclared identifier
C:\Users\HP\Desktop\C++作业\4.cpp(17) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
C:\Users\HP\Desktop\C++作业\4.cpp(20) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
C:\Users\HP\Desktop\C++作业\4.cpp(21) : error C2297: '<<' : illegal, right operand has type 'char [3]'
执行 cl.exe 时出错.
请问哪里出错了?? 展开
using namespacestd;
int main()
{
int i, j, k,n=0;
// 用n记录个数
for (i=1; i<=3; i++)
for (j=1; j<=3; j++)
for (k=0; k<=3; k++)
{
if (i!=j && j!=k && i!=k)
//判断i, j, k三位各不相同
{
cout<<i<<j<<k<<" ";
n++;
if (n%3 == 0)
cout<<endl;
}
}
cout<<endl;
cout<<"n="<<n<<endl;
return 0;
}
C:\Users\HP\Desktop\C++作业\4.cpp(2) : error C2873: 'namespacestd' : symbol cannot be used in a using-declaration
C:\Users\HP\Desktop\C++作业\4.cpp(14) : error C2065: 'cout' : undeclared identifier
C:\Users\HP\Desktop\C++作业\4.cpp(14) : error C2297: '<<' : illegal, right operand has type 'char [3]'
C:\Users\HP\Desktop\C++作业\4.cpp(17) : error C2065: 'endl' : undeclared identifier
C:\Users\HP\Desktop\C++作业\4.cpp(17) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
C:\Users\HP\Desktop\C++作业\4.cpp(20) : warning C4552: '<<' : operator has no effect; expected operator with side-effect
C:\Users\HP\Desktop\C++作业\4.cpp(21) : error C2297: '<<' : illegal, right operand has type 'char [3]'
执行 cl.exe 时出错.
请问哪里出错了?? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询