博客專欄

        EEPW首頁 > 博客 > C語言繪圖教程例子5-1

        C語言繪圖教程例子5-1

        發(fā)布人:chen3bing 時間:2024-05-15 來源:工程師 發(fā)布文章

        代碼

        #include <graphics.h>
        #include <math.h>
        
        void polygon(x0,y0,a,n,af)
        int x0,y0,a,n;
        	float af;
        {
        	
        	
        		int x,y,i;
        		float dtheta,theta;
        		if(n<3) return;
        		dtheta=6.28318/n;
        		theta=af*0.0174533;
        		moveto(x0,y0);
        		x=x0;
        		y=y0;
        		for(i=1;i<n;i++)
        		{
        			x=x+a*cos(theta);
        			y=y+a*sin(theta);
        			lineto(x,y);
        			theta=theta+dtheta;
        		}
        		lineto(x0,y0);
        	}
        
         int main()
         {
        
        	
        
        	
        	int i,a=80,x=200,y=100;
        	int gdriver=DETECT,gmode;
        	initgraph(&gdriver,&gmode,"c\\tc");
        	cleardevice();
        	setbkcolor(9);
        	setcolor(4);
        	for(i=3;i<=10;i++)
        	polygon(x,y,a,i,0); 
        
        		
        		
         getch();
         
        return 0;
         }

        運行

        1710053115378.jpg

        *博客內容為網(wǎng)友個人發(fā)布,僅代表博主個人觀點,如有侵權請聯(lián)系工作人員刪除。



        關鍵詞: C語言繪圖

        技術專區(qū)

        關閉
        主站蜘蛛池模板: 巴彦淖尔市| 罗定市| 吉安县| 大兴区| 盐山县| 晋宁县| 中江县| 吴堡县| 灌南县| 醴陵市| 石首市| 大荔县| 兰坪| 乐都县| 积石山| 杂多县| 河东区| 西藏| 手游| 皋兰县| 且末县| 南投市| 攀枝花市| 凤翔县| 宜丰县| 固安县| 理塘县| 额济纳旗| 贡觉县| 瑞金市| 元氏县| 蓬莱市| 巴楚县| 拜泉县| 衡阳县| 万盛区| 大渡口区| 华池县| 浦东新区| 新余市| 资兴市|