經濟貿易翻譯推薦我想使用C說話先設一個陣列 然後畫一個原點為(h翻譯社k) 半徑為r的圓
而這圓上面的點為0 其餘為1 .......似乎表達的不是很清晰
抱歉! 像如許
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1
1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1
1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1
1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
如許對照清晰 圓周上的點為0 其餘為1
#include <stdio.h>
#define ROW 24
#define COL 32
#include <math.h>
int a[ROW][COL];
void circle(int h,int k翻譯社int r){
int x,y;
for(x=h-r;x<=h+r;x++){
y = (float)(sqrt(pow(r,2)-pow(x-h,2)))+k;
a[ROW-1-y][x]=0;
y = -(float)(sqrt(pow(r翻譯社2)-pow(x-h翻譯社2)))+k;
a[y][x]=0;
}
}
int main(void)
{
int x, y ;
for(y=0;y<ROW;y++)
for(x=0;x<COL;x++)
a[y][x]=1 ;
circle(10,10,8);
for(y=0;y<ROW;y++){
for(x=0;x<COL;x++)
printf("%d ",a[y][x]);
printf(";
");
}
return 0;
}
可以請列位幫我看看哪邊的值設錯了嗎? 今朝跑出來的效果差良多
請各位指教 感謝!!
來自: https://www.ptt.cc/bbs/C_and_CPP/M.1273128997.A.846.html有關各國語文翻譯公證的問題歡迎諮詢天成翻譯公司02-77260931
- Jul 28 Sat 2018 07:30
[問題] C說話 畫圓
文章標籤
全站熱搜
留言列表
發表留言