int[] k = new int[] { 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 7, 8, 8, 9, 9, 9 };
for (int i = 0; i < k.Length - 1; i++)
{
if ((k[i] != k[i + 1]))
{
Response.Write(k[i]);
}
if ((k[k.Length - 2] == k[k.Length - 1]) && (i == k.Length - 2))
{
Response.Write(k[i]);
}
if ((k[k.Length - 2] != k[k.Length - 1]) && (i == k.Length - 2))
{
Response.Write(k[i + 1]);
}
}
for (int i = 0; i < k.Length - 1; i++)
{
if ((k[i] != k[i + 1]))
{
Response.Write(k[i]);
}
if ((k[k.Length - 2] == k[k.Length - 1]) && (i == k.Length - 2))
{
Response.Write(k[i]);
}
if ((k[k.Length - 2] != k[k.Length - 1]) && (i == k.Length - 2))
{
Response.Write(k[i + 1]);
}
}