From 06b3371bdc0b29d3b76600cca0dd0b32930b1369 Mon Sep 17 00:00:00 2001 From: ​ Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: most common char --- most_common_char/Most Common Character/mainForm.cs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 most_common_char/Most Common Character/mainForm.cs (limited to 'most_common_char/Most Common Character/mainForm.cs') diff --git a/most_common_char/Most Common Character/mainForm.cs b/most_common_char/Most Common Character/mainForm.cs new file mode 100644 index 0000000..7f008e6 --- /dev/null +++ b/most_common_char/Most Common Character/mainForm.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Most_Common_Character +{ + public partial class mostCommonCharacter : Form + { + public mostCommonCharacter() + { + InitializeComponent(); + } + + private void calculateBtn_Click(object sender, EventArgs e) + { + string str = inputTxtBox.Text.Replace(" ", "").ToLower(); + int commonChar = 0; + char ch = '\0'; + + for (int i = 0; i < str.Length; i++) { + int chars = 0; + + for (int j = 0; j < str.Length; j++) + if (str[i] == str[j]) + chars++; + + if (chars > commonChar) { + commonChar = chars; + ch = str[i]; + } + } + + outputLbl.Text = ch.ToString(); + } + + private void button2_Click(object sender, EventArgs e) + { + inputTxtBox.Text = ""; + outputLbl.Text = ""; + } + + private void exitBtn_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} -- cgit 1.4.1