急!!我的分都给了啊

beidoujia 2010-12-01 04:19:53
用C++做一个程序 内容是 一大一小2个小球碰撞后粘在一起,然后一起沿着大球的方向运动
明天就交作业了 速度啊
...全文
338 44 打赏 收藏 转发到动态 举报
写回复
用AI写文章
44 条回复
切换为时间正序
请发表友善的回复…
发表回复
fc_cpp 2010-12-08
  • 打赏
  • 举报
回复
#include <conio.h>
void main() {
cprintf("\r ○ 。");sleep(100);
cprintf("\r ○ 。 ");sleep(100);
cprintf("\r ○。 ");sleep(100);
cprintf("\r ○。 ");sleep(100);
cprintf("\r ○。");sleep(100);.....
效果好些
beidoujia 2010-12-08
  • 打赏
  • 举报
回复
[Quote=引用 40 楼 my_live_123 的回复:]
C/C++ code

#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
int w1=10,w2=60;
while(w2)
{
system("cls");
cout.width(w1);
cout.se……
[/Quote] 黑点在TC上怎么弄出来
beidoujia 2010-12-07
  • 打赏
  • 举报
回复
[Quote=引用 40 楼 my_live_123 的回复:]

C/C++ code

#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
int w1=10,w2=60;
while(w2)
{
system("cls");
cout.width(w1);
cout.setf(ios::ri……
[/Quote]
内个圈怎么打出来啊 在tc上面
yiyefangzhou24 2010-12-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhao4zhong1 的回复:]
C/C++ code

#include <conio.h>
void main() {
cprintf("\r ○ 。");getch();
cprintf("\r ○ 。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。");getch(……
[/Quote]
给力。。。。
一根烂笔头 2010-12-06
  • 打赏
  • 举报
回复

#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
int w1=10,w2=60;
while(w2)
{
system("cls");
cout.width(w1);
cout.setf(ios::right);
cout<<"⊙";
Sleep(50);
system("cls");
cout.width(w2);
cout.setf(ios::left);
cout<<"●";
w1++;w2--;
Sleep(50);
if(w1==w2)break;
}
while(w1)
{
system("cls");
cout.width(w1);
cout.setf(ios::left);
cout<<"●";
w1--;
Sleep(100);
}

}
我这个可行,可以试一试!那个黑点代表大球,中空的是小球
未注销 2010-12-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhao4zhong1 的回复:]

C/C++ code

#include <conio.h>
void main() {
cprintf("\r ○ 。");getch();
cprintf("\r ○ 。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。");getch();
}

……
[/Quote]
高手啊。
bcj00000 2010-12-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhao4zhong1 的回复:]

C/C++ code

#include <conio.h>
void main() {
cprintf("\r ○ 。");getch();
cprintf("\r ○ 。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。");getch();
}

……
[/Quote]


这可是代码的最高镜界啊......佩服...威武
kisshujinwen 2010-12-06
  • 打赏
  • 举报
回复
3楼。。。有创意,才够味
beidoujia 2010-12-06
  • 打赏
  • 举报
回复
[Quote=引用 33 楼 dubiousway 的回复:]
引用 28 楼 dubiousway 的回复:

引用 26 楼 beidoujia 的回复:

好吧 三楼你的内2个圆 显示的是乱码


只能tc2.0?

我16楼的不能用。你们作业,老师还一个一个测验运行吗



C/C++ code

[code=C/C++]
#include <graphics.h>
#include <stdio.h>
#inclu……
[/Quote]编译没问题。但是2个球都不动 只是一堆圈 能不能让他动起来
kingbigeast 2010-12-02
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhao4zhong1 的回复:]

C/C++ code

#include <conio.h>
void main() {
cprintf("\r ○ 。");getch();
cprintf("\r ○ 。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。");getch();
}

……
[/Quote]
<conio.h>不是标准库中的。
不过这个真的很给力。。。。。。。。。。。。。
suyumo1991 2010-12-02
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 dubiousway 的回复:]
引用 3 楼 zhao4zhong1 的回复:

C/C++ code

#include <conio.h>
void main() {
cprintf("\r ○ 。");getch();
cprintf("\r ○ 。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r……
[/Quote]

我调试过,他是往小球方向运动的...不过只要将大小换一下就可以了...
话说真的很给力...我第一想法是MFC...
LB065X 2010-12-02
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhao4zhong1 的回复:]
C/C++ code

#include <conio.h>
void main() {
cprintf("\r ○ 。");getch();
cprintf("\r ○ 。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。");getch(……
[/Quote]



狂顶!给力,太给力了!
beidoujia 2010-12-02
  • 打赏
  • 举报
回复
[Quote=引用 33 楼 dubiousway 的回复:]

引用 28 楼 dubiousway 的回复:

引用 26 楼 beidoujia 的回复:

好吧 三楼你的内2个圆 显示的是乱码


只能tc2.0?

我16楼的不能用。你们作业,老师还一个一个测验运行吗


C/C++ code

[code=C/C++]
#include <graphics.h>
#include <stdio.h>
#include <……
[/Quote]
嗯 谢谢 我试试
dubiousway 2010-12-02
  • 打赏
  • 举报
回复
[Quote=引用 28 楼 dubiousway 的回复:]

引用 26 楼 beidoujia 的回复:

好吧 三楼你的内2个圆 显示的是乱码


只能tc2.0?

我16楼的不能用。你们作业,老师还一个一个测验运行吗
[/Quote]


[code=C/C++]
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>


struct Ball{
int x,y,r;
int mass;
int v;
};
void show(struct Ball* ball){
setcolor(BLUE);
circle(ball->x,ball->y,ball->r);
}
void move(struct Ball* ball, int slp){
delay(slp);
setcolor(BLACK);
circle(ball->x,ball->y,ball->r);
ball->x+=ball->v;
setcolor(BLUE);
circle(ball->x,ball->y,ball->r);
}
void setNewPos(struct Ball* ball, int xnew,int ynew){
setcolor(BLACK);
circle(ball->x,ball->y,ball->r);
ball->x= xnew, ball->y= ynew;
show(ball);
}

int main(){

int gdriver = EGA, gmode = EGAHI;
int x1=100,x2=300,y=100,v,i;

struct Ball b1,b2;
b1.x=x1, b1.y=y, b1.r=20, b1.mass=10, b1.v=8;
b2.x=x2, b2.y=y, b2.r=10, b2.mass=5, b2.v=-3;

initgraph(&gdriver, &gmode, "c:\\programs\\tc2\\bgi");//tc安装目录下,*.bgi 文件所在目录;
//可能是 tc2 目录下,也可能还有个bgi目录

show(&b1);
show(&b2);
v= (10*8+5*-3)/(10+5);//碰撞后速度

i=80;
while(i--){
move(&b1,80);
move(&b2,80);
if(b2.x-b1.x<20+10){
b1.v=b2.v=v;
setNewPos(&b2,b1.x+20+10,y);
break;
}
}
while(i--){
move(&b1,80);
move(&b2,80);
}


getch();
closegraph();

return 0;
}



改装的,编译有问题,要把问题贴出来
[/code]
beidoujia 2010-12-02
  • 打赏
  • 举报
回复
哭了....大家别崇拜三楼了 快告诉我怎么做啊
loveincool 2010-12-02
  • 打赏
  • 举报
回复
3楼高
libra101015 2010-12-02
  • 打赏
  • 举报
回复
3楼 强人~~~~~~~
space_006 2010-12-02
  • 打赏
  • 举报
回复
三楼是大牛!。。
游牧小小诗人 2010-12-02
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhao4zhong1 的回复:]
C/C++ code

#include <conio.h>
void main() {
cprintf("\r ○ 。");getch();
cprintf("\r ○ 。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。 ");getch();
cprintf("\r ○。");getch(……
[/Quote]


艺术,神作!!膜拜!!!
beidoujia 2010-12-02
  • 打赏
  • 举报
回复
16楼辛苦了 但是你的代码不能用 我们用得是2.0 不知道老师是不是一个一个运行 我只是尽人意听天命》。 老师宽限星期日之前交上
加载更多回复(24)

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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