using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter your string");
string input = Console.ReadLine();
string input1 = input;
int c = 0;
Console.WriteLine("character occurances");
while (input.Length > 0)
{
c = 0;
Console.Write(input[0] + " : ");
for (int j = 0; j < input.Length; j++)
{
if (input[0] == input[j])
{
c++;
}
}
Console.WriteLine(c);
input = input.Replace(input[0].ToString(), string.Empty);
}
c = 0;
Console.WriteLine("Words occurances");
string[] re = input1.Split(' ');
for (int i = 0; i < re.Length; i++)
{
string temp = re[i];
for (int j = 0; j < re.Length; j++)
{
if (temp == re[j])
{
c++;
}
}
if (re[i] != string.Empty)
Console.WriteLine(re[i] + ":" + c);
for (int j = 0; j < re.Length; j++)
{
if (temp == re[j])
{
re[j] = string.Empty;
}
}
c = 0;
}
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter your string");
string input = Console.ReadLine();
string input1 = input;
int c = 0;
Console.WriteLine("character occurances");
while (input.Length > 0)
{
c = 0;
Console.Write(input[0] + " : ");
for (int j = 0; j < input.Length; j++)
{
if (input[0] == input[j])
{
c++;
}
}
Console.WriteLine(c);
input = input.Replace(input[0].ToString(), string.Empty);
}
c = 0;
Console.WriteLine("Words occurances");
string[] re = input1.Split(' ');
for (int i = 0; i < re.Length; i++)
{
string temp = re[i];
for (int j = 0; j < re.Length; j++)
{
if (temp == re[j])
{
c++;
}
}
if (re[i] != string.Empty)
Console.WriteLine(re[i] + ":" + c);
for (int j = 0; j < re.Length; j++)
{
if (temp == re[j])
{
re[j] = string.Empty;
}
}
c = 0;
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment