Discuz! Board

 找回密码
 立即注册
查看: 331|回复: 0

随机数产生

[复制链接]

574

主题

758

帖子

243万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2435189

烈空座 Lv:100
发表于 2022-10-28 19:00:04 | 显示全部楼层 |阅读模式
#include<time.h> //包含随机数,时间函数

int main()
{
        
        srand(time(0));//随机种子函数         
        
        for(int i =0;i<10;i++)
        {
                ball.x = 50+rand()%width;
                ball.y = 30+rand()%height;
                ball.vx = rand()%3;
                ball.vy = rand()%5;
                ball.radius = 10+rand()%10;        
        }

        unsigned int R_color,G_color,B_color;

[C] 纯文本查看 复制代码
		ball[i].R_color = randx(10,255);
		ball[i].G_color = randx(10,255);
		ball[i].B_color = randx(10,255);
setfillcolor(EGERGB(ball[i].R_color, ball[i].G_color, ball[i].B_color));
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-2-12 18:46 , Processed in 0.050401 second(s), 28 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.. 技术支持 by 巅峰设计

快速回复 返回顶部 返回列表