Keke_paner 2016-04-24 11:43 采纳率: 0%
浏览 1484

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条回答 默认 最新

  • suwu150 博客专家认证 2016-04-24 12:03
    关注

    你一定要使用C++吗?为何不使用VC++中的MFC组件,能够使用ondraw()函数很轻松的画出各种图形,而且界面为可视化界面

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog