jeyaseelan
BAN USERMy C# solution
Console.WriteLine("Enter the no. of rows");
int r = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the no. of columns");
int c = Convert.ToInt32(Console.ReadLine());
string[,] a = new string[r,c];
for(int i=0; i<r; i++)
{
for(int j=0; j<c; j++)
{
a[i,j] = Console.ReadLine();
}
}
Console.WriteLine("The characters of matrix is");
for(int i=0; i<r; i++)
{
for(int j=0; j<c; j++)
{
Console.Write("{0} ",a[i,j]);
}
Console.WriteLine();
}
Console.WriteLine("Enter a word");
string s = Console.ReadLine();
int m=0,flag=0;
for(int k=0; k<s.Length; k++)
{
for(int i=0; i<r; i++)
{
for(int j=0; j<c; j++)
{
char[] ch = a[i,j].ToCharArray();
if(s[k]==ch[m])
{
flag = 1;
break;
}
else
flag = 0;
}
if(flag==1)
break;
}
}
if(flag==1)
Console.WriteLine("True");
else
Console.WriteLine("False");
Console.WriteLine("Enter the array size");
int n = Convert.ToInt32(Console.ReadLine());
int[] a = new int[n];
int max=a[0],count=0;
for(int i=0; i<n; i++)
{
a[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Given array is able to reach the last index?");
for(int i=1; i<a.Length; i++)
{
if(max<a[i])
{
max = a[i];
count++;
}
}
if(a[0]==count)
Console.WriteLine("True");
else
Console.WriteLine("False");
C# solution
Console.WriteLine("Enter the string");
string s = Console.ReadLine();
int c=0,flag=0,j=0;
for (int i = 0; i < s.Length;)
{
c = 0;
for (j = 0; j < s.Length; j++)
{
if (s[i] == s[j])
{
flag = 1;
c++;
}
else if(flag==1)
{
Console.Write("{0}{1}", s[i], c);
i = j;
flag = 0;
break;
}
}
if (j == s.Length)
{
Console.Write("{0}{1}", s[i], c);
break;
}
}
Repcharlieesandobal, Security Analyst at ADP
I am Charliee , a dedicated security professional at Monsource for the last 6 years managing security teams and corporate environments ...
- jeyaseelan December 05, 2016