Advertisement
Guest User

Untitled

a guest
May 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 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 KDA1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. float k = int.Parse(Console.ReadLine());
  14.  
  15. string line = Console.ReadLine();
  16. string[] tokens = line.Split(' ');
  17. float[] numbers = Array.ConvertAll(tokens, float.Parse);
  18.  
  19. float[] number_skal = new float[numbers.Length];
  20.  
  21. float max = numbers.Max();
  22. float min = numbers.Min();
  23.  
  24. float super_max = Math.Max(Math.Abs(min), Math.Abs(max));
  25.  
  26. float s = 2 / (k+1);
  27. float t = 0;
  28.  
  29. List<float> range_x = new List<float>();
  30. List<float> range_y = new List<float>();
  31. for (int q = 0; q<k; q++)
  32. {
  33. range_x.Add(-1 + t);
  34. t += s;
  35. range_y.Add(-1 + t + s);
  36.  
  37. }
  38. Random r = new Random();
  39. int x;
  40. List<float> output = new List<float>();
  41. float z = 1;
  42.  
  43.  
  44. float delta = max - min;
  45. int i = 0;
  46. for(int q=0;q<k;q++)
  47. {
  48. Console.WriteLine("[x= " + range_x[q] + " y= " + range_y[q] + "]\t");
  49. }
  50.  
  51. foreach (float q in numbers)
  52. {
  53. number_skal[i] = (float)Math.Round((q / super_max), 0);
  54. i++;
  55. }
  56. for(int p=0;p<number_skal.Length;p++)
  57. {
  58. for(int c=0; c<range_x.Count;c++)
  59. {
  60. if (number_skal[p] >= range_x[c] && number_skal[p] < range_y[c]) output.Add(z);
  61. else z++;
  62. }
  63. }
  64. for(int p=0;p<number_skal.Length;p++)
  65. {
  66. numbers[p] = number_skal[p] * super_max;
  67. }
  68.  
  69. for(int j=0; j<number_skal.Length;j++)
  70. {
  71. Console.WriteLine(number_skal[j]);
  72. Console.WriteLine("Z: " + output.ElementAt(j));
  73. Console.WriteLine();
  74. Console.WriteLine("Nr zakodowane" + number_skal[j]);
  75. Console.WriteLine("Nr po odkodowaniu: " + numbers[j]);
  76. }
  77.  
  78. Console.WriteLine("max= " + max + " min=" + min);
  79. Console.ReadKey();
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement