Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 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 ConsoleApp4
  8. {
  9. class Program
  10. {
  11. static void MG(string adatsor, ref string[,] lista)
  12. {
  13.  
  14.  
  15. string[] seged = adatsor.Split('|');
  16. lista = new string[seged.Length, 4];
  17. for (int i = 0; i < seged.Length; i++)
  18. {
  19. string[] temp = seged[i].Split(':');
  20. for (int j = 0; j < temp.Length; j++)
  21. {
  22. lista[i, j] = temp[j];
  23. }
  24. }
  25. }
  26.  
  27. static string[] Mufajok(string[,] lista)
  28. {
  29. string seged = "";
  30.  
  31. for (int i = 0; i < lista.GetLength(0); i++)
  32. {
  33. if(!(seged.Contains(lista[i,2])))
  34. {
  35. seged += lista[i, 2]+" ";
  36. }
  37. }
  38. string[] mufajok = seged.Split('-');
  39. return mufajok;
  40. }
  41.  
  42. static bool Alternativ(string[] mf)
  43. {
  44. int i = 0;
  45. bool alt = false;
  46. while ( i < mf.Length && mf[i] != "Alterativ")
  47. {
  48. i++;
  49. }
  50. if (i < mf.Length)
  51. {
  52. alt = true;
  53. }
  54.  
  55. return alt;
  56. }
  57.  
  58. static void Main(string[] args)
  59. {
  60. string adatsor = "Kapitány Máté:JEEP:trap:1000|Michael Jackson:Thriller:pop:1562|AC/DC:Back in Black:rock:3000|Eminem:Encore:hiphop/rap:5146|30Y:Dicsőség:alternatív:880|Travis Scott:ASTROWORLD:trap/hiphop:10664|ASAP Rocky:Testing:hiphop:1364|Kapitány Máté:Ezüstfekete:trap:910";
  61. string[,] lista = new string[1,4];
  62. MG(adatsor, ref lista);
  63. /*for (int i = 0; i < lista.GetLength(0); i++)
  64. {
  65. for (int j = 0; j < lista.GetLength(1); j++)
  66. {
  67. Console.WriteLine(lista[i,j]);
  68. }
  69. }*/
  70. string[] mf = Mufajok(lista);
  71. /*for (int i = 0; i < mf.Length; i++)
  72. {
  73. Console.WriteLine(mf[i]);
  74. }*/
  75. Alternativ(mf);
  76.  
  77. Console.ReadKey();
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement