C / C ++の巨大な五芒星を描きます

一緒に朱が長時間絵付き
正弦ポイントは、五芒星の中で見て角度を変更する判決を特4つの象限の中心に対して五芒星を使用することによって決定され、角度は、ほとんど、位置のない慎重な調整がスターを指摘していない、最上部の角に変換され、醜いです

#include <bits/stdc++.h>
using namespace std;
/*    freopen("k.in", "r", stdin);
    freopen("k.out", "w", stdout); */
//clock_t c1 = clock();
//std::cerr << "Time:" << clock() - c1 <<"ms" << std::endl;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define de(a) cout << #a << " = " << a << endl
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef vector<int, int> VII;
#define inf 0x3f3f3f3f
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 1e6 + 7;
const ll MAXM = 1e6 + 7;
const ll MOD = 1e9 + 7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int vis[MAXN];
int a[MAXN];
int main()
{
    double Y = 300, X = 100;
    double c = 180.0 / pi;
    for (int i = Y; i >=1; i--)
    {
        for (int j = 2 * Y; j>=1 ; j--)
        {
            double y = i, x = j / 2;
            x -= X;
            y -= X;
            if (y == 0)
                y -= 0.01;
            double p;                       //与中心连线与y轴角度
            double r = sqrt(x * x + y * y); //到中心距离
            if (x > 0 && y > 0)
                p = atan(x / y) * c;
            else if (x >= 0 && y < 0)
                p = 180 + atan(x / y) * c;
            else if (x <= 0 && y >= 0)
                p = -atan(x / y) * c;
            else
                p = 180 - atan(x / y) * c;
            if (p >= 36 && p <= 108)
                p = fabs(p - 72.0);
            else if (p > 108)
                p = fabs(144.0 - p);
            double t = (180 - 18 - p) / 180 * pi;
            if (r / sin(18 * pi / 180) <= X / sin(t))
                putchar('*');
            else
                putchar('.');
        }
        puts("");
    }
    return 0;
}

おそらくそれは長くなります
限り

おすすめ

転載: www.cnblogs.com/graytido/p/11599880.html