彩虹

#include <graphics.h>		// 引用图形库头文件
#include <conio.h>
int f(int x,int y){
	COLORREF n[7]={RED,RGB(255, 165, 0),YELLOW,GREEN,CYAN,BLUE,RGB(128, 0, 128)};
	for(int i=0;i<x;i++){
		int cl=i/(x/7);
		for(int j=0;j<y;j++){
				putpixel(i,j,n[cl]);
		}
	}
	return 0;
}
int main()
{	
	int X=700,Y=480;
	initgraph(X,Y);
	f(X,Y);
	_getch();
	closegraph();
	return 0;
}

  

posted @ 2025-04-19 15:03  陈若麟  阅读(3)  评论(0)    收藏  举报