绘制空心圆
# include <stdio.h>
# include <math.h>
# include <stdlib.h>
#include <windows.h>
void color(short w) //自定義函根據(jù)參數(shù)改變顏色?
{
?if(w>=0 && w<=15)//參數(shù)在0-15的范圍顏色
? ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), w); ? ?//只有一個(gè)參數(shù),改變字體顏色?
?else//默認(rèn)的顏色白色
? ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
void main()
{
?? ?double y;
?? ?int x,m; system("color 7F");system("pause");
?? ?for (y=10;y>=-10;y--)
?? ?{?
?? ??? ?m = 2.2*sqrt(100-y*y);
?? ??? ?for(x=1;x<30-m;x++)
?? ??? ?{
?? ?color (5);?? ?printf(" ");
?? ??? ?}
?? ?color (4); printf("*");
?? ??? ?for( ; x<30+m; x++)
?? ??? ?{
?? ??? ??? ?color (5);printf(" ");
?? ??? ?}
color (4);?? ? system("color F4");printf("*\n");
?? ??
?? ?}
?? ?
}
?
?
總結(jié)
- 上一篇: AutoCAD的COM开发时无法获取At
- 下一篇: Vivado无法识别开发板解决办法