Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 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. using System.IO;
  7.  
  8. namespace zad2_ps3
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. char[] slowoA = new char[256];
  15. char[] slowoB = new char[256];
  16. // string text;
  17. //string[] rozdzielonyText;
  18. // int dlugosc;
  19. //int[] tablica;
  20. List <char> list = new List<char>();
  21.  
  22. StreamWriter sw = new StreamWriter("out.txt");
  23.  
  24. //using (FileStream fs = File.OpenRead("in.txt"))
  25. //{
  26. // StreamReader sr = new StreamReader(fs);
  27. // text = sr.ReadLine();
  28. // rozdzielonyText = text.Split();
  29. // dlugosc = rozdzielonyText.Length;
  30. // tablica = new int[dlugosc];
  31.  
  32. // for (int i = 0; i < dlugosc; i++)
  33. // {
  34. // tablica[i] = Convert.ToInt32(rozdzielonyText[i]);
  35.  
  36. // }
  37. //}
  38.  
  39.  
  40.  
  41.  
  42. if (slowoA.Length>slowoB.Length)
  43. {
  44. for(int i=0; i<slowoA.Length;i++)
  45. {
  46. for (int j = 0; j < slowoB.Length; j++)
  47. {
  48. if (slowoA[i] == slowoB[j])
  49. {
  50. list.Add(slowoA[i]);
  51. slowoA[i] = ('0');
  52. slowoB[j] = ('0');
  53. }
  54. }
  55. }
  56. }
  57. else for (int i = 0; i < slowoB.Length; i++)
  58. {
  59. for (int j = 0; j < slowoA.Length; j++)
  60. {
  61. if (slowoB[i] == slowoA[j])
  62. {
  63. list.Add(slowoB[i]);
  64. slowoA[i] = ('0');
  65. slowoB[j] = ('0');
  66. }
  67. }
  68. }
  69. sw.Write(list);
  70.  
  71. sw.Close();
  72.  
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement