Keke_paner 2016-04-22 03:26 采纳率: 0%
浏览 2560
已结题

小白求教C++怎样用函数输出图形

原题是这样的

二、设计以下三个函数:dispRectangle()、dispRightAngledTriangle()、dispIsoscelesTriangle(),分别用来显示由指定字符和指定行数构成的矩形、直角三角形和等腰三角形。并在主函数给出如图1所示的菜单(就是很简单的那种输入一二三的菜单,我就不写了,大神们肯定都懂),输入选项,调用相应的图形显示函数。

#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)
执行 cl.exe 时出错.

大神们,拜托帮我改一下,非常谢谢。

  • 写回答

1条回答

  • 小灸舞 2016-04-22 05:24
    关注

    建议楼主重新发一遍代码,代码放在代码便签内,报错所在的那几行有点奇怪啊cout cout cin>>f>>g; ??
    是复制的问题么?

    //放在这里
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符