俄文口譯薪資我想利用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
- Jun 23 Sat 2018 04:55
[問題] C語言 畫圓
文章標籤
全站熱搜
留言列表