-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveNoise.cs
More file actions
46 lines (36 loc) · 1.25 KB
/
Copy pathremoveNoise.cs
File metadata and controls
46 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace removeNoise
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter string with noise: "); //example: "do$%k%$im@@i"
string noise = Console.ReadLine();
Console.WriteLine(RemoveNoise(noise));
}
public static string RemoveNoise(string equation)
{
List<char> charList = new List<char>();
charList.AddRange(equation);
List<char> newCharList = new List<char>();
for (int i = 0; i < charList.Count; i++)
{
if (charList[i] != '@' && charList[i] != '$' && charList[i] != '%' && charList[i] != '#' && charList[i] != '·' && charList[i] != 'ª' && charList[i] != '/' && charList[i] != '&' && charList[i] != '|' && charList[i] != 'º' && charList[i] != 'ª' && charList[i] != '\\')
{
newCharList.Add(charList[i]);
}
}
equation = string.Empty;
foreach (var item in newCharList)
{
equation += item;
}
return equation;
}
}
}