#include <iostream>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
std::vector<std::size_t> Shuffle(std::size_t N){
std::size_t S = 0;
std::size_t E = N;
std::vector<std::size_t> vec;
bool F = true;
while (S != E){
if (F){
vec.push_back(S++);
}
else{
vec.push_back(E--);
}
F = (!F);
}
vec.push_back(S);
return vec;
}
template<class T>
struct Vector2
{
T x, y;
};
template<class T>
Vector2<T> TransForm(Vector2<T>& Length, double RotRadian, Vector2<T>& Scale, Vector2<T>& Move)
{
Vector2<T> Ret = { 0, };
double Sin = sin(RotRadian);
double Cos = cos(RotRadian);
Ret.x = ((Length.x * Scale.x) * Cos) - ((Length.y * Scale.y) * Sin) + Move.x;
Ret.y = ((Length.x * Scale.x) * Sin) + ((Length.y * Scale.y) * Cos) + Move.y;
return Ret;
}
bool MakeHoge(std::string Str){
std::vector<std::size_t> Vec = Shuffle(Str.size()-1);
double R = Str.size() / 2;
double Radian = M_PI / 180.0;
double Angle = 360.0 / Str.size();
Vector2<double> V{ 0, 0 };
Vector2<double> S{ 1, 1 };
Vector2<double> M{ R, R };
Vector2<double> L{ R, 0 };
for (std::size_t i = 0; i < Vec.size(); i++){
auto O = V;
V = TransForm(L, Radian*((Angle*Vec[i])-90), S,M);
if (i % 2 == 0) V.x = V.x - O.x;
for (int j = 0; j < (int)(V.x); j++)std::cout << ' ';
std::cout << Str[Vec[i]];
if (i % 2 == 0)std::cout << std::endl;
}
return true;
}
int main(){
std::string Str = "0123456789abc";
MakeHoge(Str);
MakeHoge("lattattarararibirabirin");
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojZGVmaW5lIF9VU0VfTUFUSF9ERUZJTkVTCiNpbmNsdWRlIDxtYXRoLmg+CgpzdGQ6OnZlY3RvcjxzdGQ6OnNpemVfdD4gU2h1ZmZsZShzdGQ6OnNpemVfdCBOKXsKCXN0ZDo6c2l6ZV90IFMgPSA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