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;
- using System.IO;
- namespace sistemiOdlocanja1
- {
- class Program
- {
- public static List<string[]> readCSV(String filename)
- {
- List<string[]> result = new List<string[]>();
- try
- {
- string[] vrstice = File.ReadAllLines(filename);
- foreach (string vrstica in vrstice)
- {
- string[] vrednosti = vrstica.Split(',');
- result.Add(vrednosti);
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("Napaka pri branju: '{0}'", e);
- }
- return result;
- }
- static void Main(string[] args)
- {
- List<string[]> podatki = readCSV("osnovne_metode1.csv");
- int prvi = 0;
- int[,] podatek = new int[podatki.Count -1,podatki[1].Length -1];
- foreach (var item in podatki)
- {
- if(prvi == 0)
- {
- prvi++;
- }
- else
- {
- for (int i = 1; i < item.Length; i++)
- {
- podatek[prvi -1, i-1] = int.Parse(item[i]);
- // Console.WriteLine(podatek[prvi - 1, i-1]);
- }
- prvi++;
- }
- }
- // int opt = Optimist(podatek);
- // int pes = Pesimist(podatek);
- // int lap = Laplace(podatek);
- // Console.WriteLine(opt);
- // Console.WriteLine(pes);
- // Console.WriteLine(lap);
- // Console.WriteLine(Savage(podatek));
- Console.WriteLine(Hurwitz(podatek));
- Console.ReadLine();
- }
- public static int Optimist(int[,] podatek)
- {
- int absmax = 0;
- for(int i = 0; i < podatek.GetLength(1); i++)
- {
- int max = 0;
- for(int j = 0; j < podatek.GetLength(0); j++)
- {
- if(podatek[j,i] > max)
- {
- max = podatek[j, i];
- }
- }
- if (max > absmax)
- {
- absmax = max;
- }
- }
- return absmax;
- }
- public static int Pesimist(int[,] podatek)
- {
- int absmax = 0;
- for (int i = 0; i < podatek.GetLength(1); i++)
- {
- int max = Int32.MaxValue;
- for (int j = 0; j < podatek.GetLength(0); j++)
- {
- if (podatek[j, i] < max)
- {
- max = podatek[j, i];
- }
- }
- if (max > absmax)
- {
- absmax = max;
- }
- }
- return absmax;
- }
- public static int Laplace(int[,] podatek)
- {
- int absmax = 0;
- for (int i = 0; i < podatek.GetLength(1); i++)
- {
- int max = 0;
- for (int j = 0; j < podatek.GetLength(0); j++)
- {
- max += podatek[j, i];
- }
- max = max / podatek.GetLength(0);
- if (max > absmax)
- {
- absmax = max;
- }
- }
- return absmax;
- }
- public static int Savage(int[,] podatek)
- {
- int absmax = Int32.MaxValue;
- int maxprvi = 0;
- int maxdrugi = 0;
- for(int x = 0; x < podatek.GetLength(0); x++) {
- for(int y = 0; y < podatek.GetLength(1); y++)
- {
- if(x== 0)
- {
- if (podatek[x, y] > maxprvi)
- {
- maxprvi = podatek[x, y];
- }
- }
- else if (x == 1)
- {
- if (podatek[x, y] > maxdrugi)
- {
- maxdrugi = podatek[x, y];
- }
- }
- }
- }
- for (int i = 0; i < podatek.GetLength(1); i++)
- {
- int razlika1 = 0;
- int razlika2 = 0;
- for (int j = 0; j < podatek.GetLength(0); j++)
- {
- if(j == 0)
- {
- razlika1 = maxprvi - podatek[j, i];
- }
- if (j == 1)
- {
- razlika2 = maxdrugi - podatek[j, i];
- }
- }
- int max = 0;
- if (razlika1> razlika2)
- {
- max = razlika1;
- }
- else
- {
- max = razlika2;
- }
- if (max < absmax)
- {
- absmax = max;
- }
- }
- return absmax;
- }
- public static int Hurwitz(int[,] podatek)
- {
- int absmax = 0;
- string[,] stevila = new string[12, podatek.GetLength(1)+1];
- for(int k = 1; k < 12; k++)
- {
- double temp = (k - 1.0) / 10.0;
- stevila[k, 0] = temp.ToString();
- Console.WriteLine(stevila[k,0]);
- }
- for (int i = 0; i < podatek.GetLength(1); i++)
- {
- int razlika = podatek[1,i] - podatek[0,i];
- for(int j = 1; j < 12; j++)
- {
- stevila[j, i] = (podatek[0,i] + Convert.ToDouble( stevila[j,0]) * razlika).ToString();
- Console.WriteLine("$$$" + stevila[j, i]);
- }
- }
- return absmax;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement