Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace KDA1
- {
- class Program
- {
- static void Main(string[] args)
- {
- float k = int.Parse(Console.ReadLine());
- string line = Console.ReadLine();
- string[] tokens = line.Split(' ');
- float[] numbers = Array.ConvertAll(tokens, float.Parse);
- float[] number_skal = new float[numbers.Length];
- float max = numbers.Max();
- float min = numbers.Min();
- float super_max = Math.Max(Math.Abs(min), Math.Abs(max));
- float s = 2 / (k+1);
- float t = 0;
- List<float> range_x = new List<float>();
- List<float> range_y = new List<float>();
- for (int q = 0; q<k; q++)
- {
- range_x.Add(-1 + t);
- t += s;
- range_y.Add(-1 + t + s);
- }
- Random r = new Random();
- int x;
- List<float> output = new List<float>();
- float z = 1;
- float delta = max - min;
- int i = 0;
- for(int q=0;q<k;q++)
- {
- Console.WriteLine("[x= " + range_x[q] + " y= " + range_y[q] + "]\t");
- }
- foreach (float q in numbers)
- {
- number_skal[i] = (float)Math.Round((q / super_max), 0);
- i++;
- }
- for(int p=0;p<number_skal.Length;p++)
- {
- for(int c=0; c<range_x.Count;c++)
- {
- if (number_skal[p] >= range_x[c] && number_skal[p] < range_y[c]) output.Add(z);
- else z++;
- }
- }
- for(int p=0;p<number_skal.Length;p++)
- {
- numbers[p] = number_skal[p] * super_max;
- }
- for(int j=0; j<number_skal.Length;j++)
- {
- Console.WriteLine(number_skal[j]);
- Console.WriteLine("Z: " + output.ElementAt(j));
- Console.WriteLine();
- Console.WriteLine("Nr zakodowane" + number_skal[j]);
- Console.WriteLine("Nr po odkodowaniu: " + numbers[j]);
- }
- Console.WriteLine("max= " + max + " min=" + min);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement