Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 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 PermuteStrings
  8. {
  9. class Program
  10. {
  11.  
  12. static bool IsPermute(string fstr, string sstr)
  13. {
  14.  
  15. if (fstr.Length == sstr.Length)
  16. {
  17. int sum1 = 0;
  18. int sum2 = 0;
  19. foreach(char chr in fstr)
  20. {
  21. sum1 += chr;
  22. }
  23. foreach(char chr in sstr)
  24. {
  25. sum2 += chr;
  26. }
  27. return (sum1 == sum2);
  28. }
  29. else
  30. {
  31. return false;
  32. }
  33.  
  34. }
  35.  
  36. static void Main(string[] args)
  37. {
  38. string firstStr = "qwertyui opasdfgh jklzxcv bnm";
  39. string secondStr = "qazwsx edcrf vtgbyhn ujmikolp";
  40. bool answer = IsPermute(firstStr, secondStr);
  41. Console.WriteLine("Answer is: " + answer);
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement