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; ??
    是复制的问题么?

    //放在这里
    
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮