Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. onFunct("abcd\n", "dCab\n");
  14. }
  15.  
  16. static void onFunct(string caseSensitive, string anagram)
  17. {
  18. int indexRep = caseSensitive.ToList().BinarySearch('\n');
  19. if (indexRep >= 0)
  20. {
  21. caseSensitive.Replace('\n', 'a');
  22. }
  23.  
  24. indexRep = anagram.ToList().BinarySearch('\n');
  25. if (indexRep >= 0)
  26. {
  27. anagram.Replace('\n', 'a');
  28. }
  29.  
  30. caseSensitive.Trim();
  31. anagram.Trim();
  32. if (caseSensitive.ToUpper() != anagram.ToUpper() && caseSensitive.Length == anagram.Length)
  33. {
  34. int count = 0;
  35. List<string> x = new List<string>();
  36. List<string> y = new List<string>();
  37.  
  38. foreach (var item in caseSensitive)
  39. {
  40. x.Add(item.ToString().ToUpper());
  41. }
  42. foreach (var item in anagram)
  43. {
  44. y.Add(item.ToString().ToUpper());
  45. }
  46.  
  47. for (int j = 0; j < y.Count; j++)
  48. {
  49. int index = x.BinarySearch(y[j]);
  50. if (index >= 0)
  51. {
  52. count++;
  53. }
  54. }
  55.  
  56. Console.WriteLine(count);
  57. if (count == caseSensitive.Length)
  58. {
  59. Console.WriteLine("case ");
  60. }
  61. }
  62. else
  63. {
  64. Console.WriteLine("dn einai");
  65. }
  66.  
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement