Guest User

Untitled

a guest
Jun 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. public static void ToVec(int[,] mat)
  2. {
  3. int i,j;
  4. int[] vec = new int[mat.GetLength(0) * mat.GetLength(0)];
  5. int counter = 0;
  6. for ( i = 0; i < mat.GetLength(0); i++)
  7. {
  8. for ( j = 0; j < mat.GetLength(0); j++)
  9. {
  10. vec[counter] = mat[i, j];
  11. counter++;
  12. }
  13. }
  14.  
  15.  
  16. int degel = 1, mone = 0, c = 0;
  17. while (c < vec.Length)
  18. {
  19. degel = 1;
  20. for (i = 0; i < vec.Length; i++)
  21. {
  22. if ((vec[c] == vec[i])&&(c!=i))
  23. degel = 0;
  24. }
  25. if (degel == 1)
  26. {
  27. mone++;
  28. }
  29. c++;
  30. }
  31.  
  32.  
  33. int[] vec2 = new int[mone];
  34. c = 0;
  35. counter=0;
  36. while (c < vec.Length)
  37. {
  38. degel = 1;
  39. for (i = 0; i < vec.Length; i++)
  40. {
  41. if ((vec[c] == vec[i]) && (c != i))
  42. degel = 0;
  43. }
  44. if (degel == 1)
  45. {
  46. vec2[counter] = vec[c];
  47. counter++;
  48. }
  49. c++;
  50. }
  51.  
  52.  
  53. for ( i = 0; i < vec2.Length; i++)
  54. {
  55. Console.Write(vec2[i] + " ");
  56. }
  57. }
Add Comment
Please, Sign In to add comment