求助c++简单应用程序!!

loveflydhl 2011-01-13 12:25:35
本人不会c++,代朋友发,能解决的帮忙一下,应该占不了多长时间
-------------*---------------
------------***--------------
-----------*****-------------
----------*******------------
---------*********-----------
--------***********----------
-------*************---------
------***************--------
----------*******------------
---------*********-----------
--------***********----------
-------*************---------
------***************--------
-----*****************-------
----*******************------
---*********************-----
--***********************----
------------***--------------
------------***--------------
------------***--------------
------------***--------------
------------***--------------
------------***---------------
用C++帮我做一个这个树的形状,尺寸大小是23*23的,最好用if else来做。然后就是需要添加一个preference setting 的功能,这个功能里面包含
另外几个功能。1.可以改变尺寸,2.可以改变这个这些符号出现的速度。3.可以改变背景,比如说可以用@ #符号来做。如果可以的话能在一些关键语句和方程后面加一些备注。我听
老师说好像可以添加颜色和一些特效,比如说闪烁,反正就是把这棵树弄的漂亮点。不知道行不行,非常感谢,新年快乐!!
...全文
239 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxwagyp1205 2011-03-03
  • 打赏
  • 举报
回复
帮顶!
gggjhk 2011-03-03
  • 打赏
  • 举报
回复
谢谢不知哪位大侠能帮小弟开发一个小程序,谢谢
good778899 2011-02-08
  • 打赏
  • 举报
回复

#include<iostream>
using namespace std;
//定义一个类;
class A
{
public:
A(int Width,int Height)//Width(宽),Height(高);
{
W=Width;
H=Height;
b=0;
}
void hua(int cc=1)//三角;
{
if(cc==1)
c=-1;
else c=cc-2;

while(H>0)
{
c+=2;
b=(W-c)/2;
for(int s=0;s<=b;s++)
cout<<"-";
for(int s=0;s<c;s++)
cout<<"*";
for(int s=0;s<=b;s++)
cout<<"-";
cout<<endl;

H--;
}
}
void go(int cc)//长条
{
b=(W-cc)/2;
c=cc;
while(H>0)
{
for(int s=0;s<=b;s++)
cout<<"-";
for(int s=0;s<c;s++)
cout<<"*";
for(int s=0;s<=b;s++)
cout<<"-";
H--;
cout<<endl;
}
}

private:
int W;
int H;
int b,c;
};

int main(int argc, char* argv[])
{
A a(29,10);//第一个
a.hua();
A b(29,10);//第二个
b.hua(7);
A c(29,10);//第三个
c.go(3);
Sleep(10000);//等待10秒
return 0;
}

在BCB6.0上能通过
开裆裤 2011-01-27
  • 打赏
  • 举报
回复
比不上第一个简单,担待点。。。。。

#include<iostream>
using namespace std;
int length,width;
void display(int wid,int len,char firstchar,char secondchar,int stage){
int count;
if(stage==1) count=1;
else count=wid/3;
while(len!=0){
for(int i=1;i<=(wid-count)/2;i++) cout<<firstchar;
for(int i=(wid-count)/2+1;i<=(wid-count)/2+count;i++) cout<<secondchar;
for(int i=(wid-count)/2+count+1; i<=wid;i++)cout<<firstchar;
cout<<endl;
count+=2;
len--;
}
}
int main(){
char fchar,schar;
cout<<"请输入行数:"<<endl;
cin>>length;
cout<<"请输入列数:"<<endl;
cin>>width;
cout<<"请输入显示的两种字符:"<<endl;
cin>>fchar>>schar;
display(width,length/3,fchar,schar,1);
display(width,length/3,fchar,schar,2);
for(int i=1;i<=length-length/3*2;i++){
for(int j=1;j<=width/3;j++) cout<<fchar;
for(int j=1;j<=width/3;j++) cout<<schar;
for(int j=2; j<=width-width/3*2;j++)cout<<fchar;
cout<<endl;
}
return 0;
}
dfdscx 2011-01-27
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 hemiya 的回复:]
来个复杂的,其实1楼的最简单。

C/C++ code

#include <iostream>

using namespace std;

void PrintChar(char ch, int count)
{
for (int i=0; i<count; i++)
cout << ch;
}

void Display(char firs……
[/Quote]还不够复杂,LZ还要闪烁彩色
开裆裤 2011-01-27
  • 打赏
  • 举报
回复
对于颜色,看下这个帖子:
http://zhidao.baidu.com/question/148665354
延迟嘛,在前面加上time.h,然后调用sleep函数就好了。参见:
http://zhidao.baidu.com/question/85953068.html?si=2
fatezhou 2011-01-26
  • 打赏
  • 举报
回复
这种类的,如果没有一个算法,靠自己像一楼那样去打印也是可以的,好吧,我也只会一楼的方法
draculamx 2011-01-26
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 sxqinge 的回复:]
这不就是个杨辉三角程序吗?
楼主可以仿照写下啊
[/Quote]
这个和杨辉三角还真没什么关系。。。
gyj_china 2011-01-20
  • 打赏
  • 举报
回复
提供以下思路
第一步三角形
-------------*---------------
------------***--------------
-----------*****-------------
----------*******------------
---------*********-----------
--------***********----------
-------*************---------
------***************--------
第二步梯形
----------*******------------
---------*********-----------
--------***********----------
-------*************---------
------***************--------
-----*****************-------
----*******************------
---*********************-----
--***********************----
第三步矩形
------------***--------------
------------***--------------
------------***--------------
------------***--------------
------------***--------------
------------***--------------
xjq2003 2011-01-20
  • 打赏
  • 举报
回复
[Quote=引用楼主 loveflydhl 的回复:]
本人不会c++,代朋友发,能解决的帮忙一下,应该占不了多长时间
-------------*---------------
------------***--------------
-----------*****-------------
----------*******------------
---------*********-----------
--------****……
[/Quote]围观
hemiya 2011-01-20
  • 打赏
  • 举报
回复
main里面的lines应该改为width
hemiya 2011-01-20
  • 打赏
  • 举报
回复
来个复杂的,其实1楼的最简单。

#include <iostream>

using namespace std;

void PrintChar(char ch, int count)
{
for (int i=0; i<count; i++)
cout << ch;
}

void Display(char firstChar, char secondChar, int lines, int width, int secondCharMin, int secondCharMax)
{
for (int i=0; i<lines; i++)
{
PrintChar(firstChar, (width - secondCharMin) / 2);
PrintChar(secondChar, secondCharMin);
PrintChar(firstChar, (width - secondCharMin) / 2);
cout << endl;

if (secondCharMin < secondCharMax)
secondCharMin += 2;
}
}

int main()
{
const char ch1 = '-';
const char ch2 = '*';
const int lines = 27;

Display(ch1, ch2, 8, lines, 1, 15);
Display(ch1, ch2, 9, lines, 7, 23);
Display(ch1, ch2, 6, lines, 3, 3);

return 0;
}


肆水東澤 2011-01-20
  • 打赏
  • 举报
回复

每一行都可以分为一步
sxqinge 2011-01-19
  • 打赏
  • 举报
回复
这不就是个杨辉三角程序吗?
楼主可以仿照写下啊
一木浮生 2011-01-13
  • 打赏
  • 举报
回复
你可以用你会的语言写个程序 帮你翻译一下可以

但是要给你写 大虾没时间 小虾太废时间
HKCID 2011-01-13
  • 打赏
  • 举报
回复
这么多细节的东西谁愿意帮你搞,下面是工具生成的。
char *fk= "
-------------*---------------\r\n\
------------***--------------\r\n\
-----------*****-------------\r\n\
----------*******------------\r\n\
---------*********-----------\r\n\
--------***********----------\r\n\
-------*************---------\r\n\
------***************--------\r\n\
----------*******------------\r\n\
---------*********-----------\r\n\
--------***********----------\r\n\
-------*************---------\r\n\
------***************--------\r\n\
-----*****************-------\r\n\
----*******************------\r\n\
---*********************-----\r\n\
--***********************----\r\n\
------------***--------------\r\n\
------------***--------------\r\n\
------------***--------------\r\n\
------------***--------------\r\n\
------------***--------------\r\n\
------------***---------------\r\n\
";
#include <fstream.h>
int main()
{
cout>>fk;
}

也算成了,快拿分来,哈哈。

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧