跳到正文

题解

题解:AT_past202306_c 円の描画

Sunsgne约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年12月26日
收录
2026年3月2日
更新
2026年11月10日
篇幅
约 1 分钟

版本

  1. v1当前

思路

模拟题意,运用两点间距离公式判断当前点到圆心的距离与圆半径的关系即可。

两点间距离公式:设点 A(x1,y1)A(x_1,y_1),B(x2,y2)B(x_2,y_2),则 AB=(x2−x1)2+(y2−y1)2AB = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}。

Code

C++
#include <bits/stdc++.h>
using namespace std;
int x,y,r,n;
signed main() {
    cin>>x>>y>>r>>n;
    for (int i=-n;i<=n;i++) {
        for (int j=-n;j<=n;j++) {
            if (sqrt((i-x)*(i-x)+(j-y)*(j-y))<=r) cout<<"# ";
            else cout<<". ";
        }
        cout<<endl;
    }
    return 0;
}

AC 记录

原文
抓取于
  1. Caged_Bird

    sto orz