#include<iostream>
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
using namespace std;
struct startu {
int xstar; //星星的X坐标
int ystar; //星星的Y坐标
unsigned radius; //星星的半径
int pigment; //星星的颜色
int margin; //星星的间隔
};
struct startu sttu[100];
void star(int i) {
int ro = 0;
sttu[i].xstar = rand() % 600;
sttu[i].ystar = rand() % 400;
sttu[i].radius = 1 + rand() % 3;
sttu[i].margin = 1 + rand() % 5;
ro = 255 * sttu[i].margin / 5;
sttu[i].pigment = RGB(ro,ro,ro);
}
int main(void) {
initgraph(600, 600);
for(int i = 0; i < 100; i++) {
star(i);
}
for (int i = 0; i < 100; i++) {
setcolor(sttu[i].pigment);
solidcircle(sttu[i].xstar,sttu[i].ystar,sttu[i].radius);
}
system("pause");
return 0;
}
用c\c++实现的效果