Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
if Two Words Are Anagrams of Each Other
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static char[] SortChrArray(char[] arrVal) { char temp; for (int i = 0; i <= arrVal.Length-1; i++) { for (int j = i+1; j < arrVal.Length; j++) { if (arrVal[i] < arrVal[j]) { temp = arrVal[i]; arrVal[i] = arrVal[j]; arrVal[j] = temp; } } } return arrVal; } public static void Main(string[] args) { //C# program to Determine if Two Words Are Anagrams of Each Other //Two words are said to be Anagrams of each other if they share the same set of letters to form the respective words. //for an example: Silent–>Listen, post–>opts.? //Builin array functions and LINQ are not allowed. Console.WriteLine("Start here..."); string str1 = "Listens"; string str2 = "Silent"; char[] ch1 = str1.ToLower().ToCharArray(); char[] ch2 = str2.ToLower().ToCharArray(); string val1 = new string(Program.SortChrArray(ch1)); string val2 = new string(Program.SortChrArray(ch2)); if (val1 == val2) { Console.WriteLine("Anagrams"); } else { Console.WriteLine("Not Anagrams"); } } } }
run
|
edit
|
history
|
help
0
Main 5.4
Task 1_3
Việc Làm
C# managing ISO 8601 dates and times
Math 9.6
Fortnite Generator
Problem_fb_series
Gen inheritance test
using @ to prefix a string
Find X numbers of 6 in row (dices)