ts.bharath
BAN USERusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace series
{
class Program
{
static void Main(string[] args)
{
Int64 num = 12;
string strOut = num.ToString();
for(int i = 0; i < 10; i++)
{
Console.Write(strOut + " ");
strOut = PrintSeries(num);
Int64.TryParse(strOut,out num);
}
//PrintSeries(1);
Console.Read();
}
static string PrintSeries(Int64 num)
{
string temp, strOut = string.Empty;
int count = 1;
temp = num.ToString();
char prev = temp[0];
int length = temp.Length;
for (int i = 1; i < length; i++)
{
if (temp[i] == prev)
{
count++;
}
else if (temp[i] != prev)
{
strOut = strOut + count.ToString() + prev.ToString();
count = 1;
prev = temp[i];
}
if (i + 1 == length)
{
strOut = strOut + count.ToString() + prev.ToString();
count = 1;
prev = temp[i];
}
}
if (length == 1)
{
strOut = count.ToString() + temp;
}
return strOut;
}
}
}
Reptabithalaws245, Computer Scientist at Absolute Softech Ltd
I am a Quality auditor Friendly technicians with over six years experience solving customer technical issues quickly and effectively. and ...
using System;
- ts.bharath March 05, 2015using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace series
{
class Program
{
static void Main(string[] args)
{
Int64 num = 12;
string strOut = num.ToString();
for(int i = 0; i < 10; i++)
{
Console.Write(strOut + " ");
strOut = PrintSeries(num);
Int64.TryParse(strOut,out num);
}
//PrintSeries(1);
Console.Read();
}
static string PrintSeries(Int64 num)
{
string temp, strOut = string.Empty;
int count = 1;
temp = num.ToString();
char prev = temp[0];
int length = temp.Length;
for (int i = 1; i < length; i++)
{
if (temp[i] == prev)
{
count++;
}
else if (temp[i] != prev)
{
strOut = strOut + count.ToString() + prev.ToString();
count = 1;
prev = temp[i];
}
if (i + 1 == length)
{
strOut = strOut + count.ToString() + prev.ToString();
count = 1;
prev = temp[i];
}
}
if (length == 1)
{
strOut = count.ToString() + temp;
}
return strOut;
}
}
}