一个随机位置函数
来源:互联网 发布:three.js 编辑器 编辑:程序博客网 时间:2024/06/10 00:22
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<windows.h>
using namespace std;
/**********************************************************/
/*****************class dog function***************************/
class living
{
public:
living(){};
virtual void display()=0;
};
class CDog :public living
{
private:
int age;
int psx;
int psy;
public:
CDog(){psx=0;psy=0;age=1;}
CDog(int x,int y,int z){psx=x;psy=y;age=z;}
int position()
{
int temp;
int seed;
seed=time(NULL);
srand(seed);
temp=rand()%5;
switch(temp)
{case 0:break;
case 1:psy=psy+1;break;
case 2:psy=psy-1;break;
case 3:psx=psx+1;break;
case 4:psx=psx-1;break;}
if(psx>100){psx-=2;};
if(psx<-100){psx+=2;};
if(psy>100){psy-=2;};
if(psy<-100){psy+=2;};
}
void display()
{ // sleep(1);
cout<<psx<<"/t"<<psy<<"/t"<<endl;
}
};
/**********************************************************/
/*****************main function***************************/
int main(void)
{
living *ptr;
CDog d1(0,0,1);
while(1)
{ Sleep(10);
d1.position();
d1.display();
}
}
- 一个随机位置函数
- unity3d 随机位置 随机时间生成一个敌人
- 一个不错的随机函数
- 写一个随机洗牌函数
- 通过随机函数生成一个随机的数组
- 一个生成随机密码的函数
- 一个获得随机字符串的asp函数
- 一个获得随机字符串的asp函数
- 给一个生成随机码的函数
- 给一个生成随机码的函数
- 一个简单的随机函数(转azure)
- 一个获得随机字符串的asp函数
- 一个获得随机字符串的asp函数
- 一个产生随机密码的函数
- 一个产生随机密码的php函数
- 一个生成验证的随机函数
- srand函数随机产生一个数_1
- 分享一个带权随机函数
- 首届“华为杯”软件编程设计大赛
- Case Study: The Investigation of an installer build only defect
- 实业优则投资:危险的游戏
- JSVM9.19.9中YuvBufferCtrl的作用
- CSS学习资源集合
- 一个随机位置函数
- Apache和迅雷对于80端口冲突的解决方案
- 实验: FEC纠错编码的验证
- uC/OS-II源码分析(一)
- window.history.go(-1)返回上页的同时刷新
- IE6下显示透明的PNG图片
- socket端口定义大全
- hibernate之多态关联(多态的多对一关联或者多态的一对一关联,利用union-subclass)
- Android 画图方式总结