peterpaner 于 2016.04.24 19:43 提问

C++小白求教怎样用函数输出图形，拜托拜托，在线等

#include
using namespace std;
void dispRectangle(int,int,char);
void dispRightAngledTriangle(int,char);
void dispIsoscelesTriangle(int,char);
int main()
{
int a,b,c,d,e,f,g,k;
do{
cout<<"1.输出矩形"< cout cout int xuhao;
cin>>xuhao;
switch(xuhao)
{
case 1:
cout<<"你选择了矩形"< cout cin>>a>>b>>c;
cout< break;
case 2:
cout cout cin>>d,e;
cout< break;
case 3:
cout cout cin>>f>>g;
cout< break;
default:
cout }
cout cin>>k;
}
while(k==1);
return 0;
}
void dispRectangle(int a,int b,char c)
{
for(int i=0;i<a;i++)
for(int j=0;j<b;j++)
cout<<b<<endl;
}
void dispRightAngledTriangle(int d,char e)
{
for(int i=0;i<d;i++)
{
for(int j=0;j<=i;j++)
cout<<e<<endl;
}
}
void dispIsoscelesTriangle(int f,char g)
{
for(int i=0;i<f;i++)
{
for(int j=0;j<=f-i-1;j++)
cout<<" "<<endl;
for(int w=0;w<2*i+1;w++)
cout<<g<<endl;
}
}

cpp(21) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
cpp(27) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
cpp(33) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)

1个回答

suwu150   2016.04.24 20:03