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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退