Skip to content

Instantly share code, notes, and snippets.

@tilongzs
Created August 11, 2021 09:21
Show Gist options
  • Save tilongzs/2d109a4b7c53cebac5bfad29de38e00d to your computer and use it in GitHub Desktop.
Save tilongzs/2d109a4b7c53cebac5bfad29de38e00d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int r = 20;
for (int z = 0; z <= 2 * r; z += 2) {
int x = (int)round(r - sqrt(r * r - (r - z) * (r - z)));
int l = 2 * (r - x);
for (int i = 0; i <= x; i++) {
printf(" ");
}
printf("*");
for (int i = 0; i < l; i++) {
printf(" ");
}
printf("*");
printf("\r\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment