CSharp · Console
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
string entrada = Console.ReadLine();
int convertido = Convert.ToInt32(entrada);
List<string> seq = new List<string>();
for(int i = convertido % 2; i <= convertido; i = i + 2 )
{
seq.Add(new String('*', i));
}
List<string> seqInv = new List<string>();
seqInv.AddRange(seq);
seqInv.RemoveAt(seqInv.Count -1);
seqInv.Reverse();
seq.AddRange(seqInv);
foreach(string item in seq)
{
Console.WriteLine(new String(' ', convertido - (item.ToString().Length/2)) + item);
}
Console.ReadLine();
}
}