walec91

Wykład tab

Nov 20th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp10
  4. {
  5.     internal class Program
  6.     {
  7.         private static void Main(string[] args)
  8.         {
  9.             #region TabliceJednoWymiarowe
  10.             int[] burok;
  11.             double[] ogórek = { 1, 2, 4, 5, 6, 7, 8, 9, 0, 4 };
  12.             int[] krowa = new int[] { 1, 2, 3, 4, 6 };
  13.             double[] ziemniak = new double[10];
  14.             ziemniak[0] = 12;
  15.  
  16.             double[] batat = new double[4] { 34, 423, 234, 22 };
  17.             double[] batat_kopia = batat;
  18.             batat = new double[3];
  19.             if (batat_kopia.Length > batat.Length)
  20.             {
  21.                 batat = new double[batat_kopia.Length];
  22.             }
  23.             for (int i = 0; i < batat_kopia.Length; i++)
  24.             {
  25.                 batat[i] = batat_kopia[i];
  26.             }
  27.             batat_kopia = null;
  28.             #endregion
  29.             #region TabliceWieloWymiarowe
  30.             string[,] NazwiskoImie = new string[2, 2] { { "", "" }, { "Nowak", "Henryk" } };
  31.             NazwiskoImie[0, 0] = "Kowalski";
  32.             NazwiskoImie[0, 1] = "Jan";
  33.             var a = NazwiskoImie[1, 1] + "" + NazwiskoImie[1, 0];
  34.             #endregion
  35.             #region TabliceParametryczne
  36.             TablicaParametryczna tp = new TablicaParametryczna();
  37.             int wartośćSumy = tp.DodajElementy(4, 233, 23, 1, 2, 3);
  38.             #endregion
  39.             Console.ReadKey();
  40.  
  41.         }
  42.     }
  43.     #region TworzenieTablicyParametrycznej
  44.     class TablicaParametryczna
  45.     {
  46.         public int DodajElementy(params int[] tablica)
  47.         {
  48.             int suma = 0;
  49.             foreach (var item in tablica)
  50.             {
  51.                 suma += item;
  52.             }
  53.             return suma;
  54.         }
  55.     }
  56.     #endregion
  57. }
Add Comment
Please, Sign In to add comment