Advertisement
barybatle

tablice

Dec 20th, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.02 KB | None | 0 0
  1. using System;
  2.  
  3. namespace tablice
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.         }
  10.         static double ZuzyciePaliwa(double dystans, double zuzyte)
  11.         {
  12.             if (dystans < 0 || zuzyte < 0)
  13.             {
  14.                 return 0;
  15.             }
  16.  
  17.             double value = (zuzyte / dystans) * 100;
  18.  
  19.             return value;
  20.         }
  21.         static double SredniaWazona(double[] oceny, int[] wagi)
  22.         {
  23.             if (oceny.Length != wagi.Length)
  24.             {
  25.                 return 0;
  26.             }
  27.  
  28.             double[] policzone = new double[oceny.Length];
  29.  
  30.             double sum = 0;
  31.  
  32.             double sumWag = 0;
  33.  
  34.             for (int i = 0; i < wagi.Length; i++)
  35.             {
  36.                 policzone[i] = oceny[i] * wagi[i];
  37.  
  38.                 sumWag = wagi[i];
  39.  
  40.                 sum += policzone[i];
  41.             }
  42.  
  43.             double value = sum / sumWag;
  44.  
  45.             return value;
  46.         }
  47.         static bool[] CzyX(double[] wartosci, double x, out int ile)
  48.         {
  49.             bool[] wynik = new bool[wartosci.Length];
  50.  
  51.             ile = 0;
  52.  
  53.             for (int i = 0; i < wartosci.Length; i++)
  54.             {
  55.                 if (wartosci[i] > x)
  56.                 {
  57.                     wynik[i] = true;
  58.                     ile++;
  59.                 }
  60.                 else wynik[i] = false;
  61.             }
  62.             return wynik;
  63.  
  64.         }
  65.         static void Zamien(int[] tab, int idx1, int idx2)  //tutaj tablicy nie wiedzialem jaki typ tablicy to dalem inty
  66.         {
  67.             int temp = tab[idx1];
  68.  
  69.             tab[idx1] = tab[idx2];
  70.  
  71.             tab[idx2] = temp;
  72.         }
  73.         static int[] Odwroc(int[] tab) //tutaj tablicy nie wiedzialem jaki typ tablicy to dalem inty
  74.         {
  75.             int[] tab2 = new int[tab.Length];
  76.  
  77.             for (int i = 0; i < tab.Length; i++)
  78.             {
  79.                 tab2[i] = tab[tab.Length - i - 1];
  80.  
  81.             }
  82.             return tab2;
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement