Advertisement
Nemo048

Untitled

Aug 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 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 lesson5_potok4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var array = new[] { 1, 2, 3 };
  14.  
  15.             Console.WriteLine(Sum(array));
  16.             /*int[] array = new int[4] { 1, 2, 3, 4};
  17.             int[] array2 = new int[4];
  18.  
  19.             for (int i = 0; i < array.Length; i++)
  20.             {
  21.                 array2[i] = array[i];
  22.             }
  23.  
  24.             foreach(int n in array)
  25.             {
  26.                 Console.WriteLine(n);
  27.             }
  28.  
  29.             Change(array2);
  30.  
  31.             Console.WriteLine();
  32.  
  33.             foreach (int n in array)
  34.             {
  35.                 Console.WriteLine(n);
  36.             }
  37.  
  38.             /*int[] arrayOneDim = new int[4];
  39.  
  40.             for(int i = 0; i < arrayOneDim.Length; i++)
  41.             {
  42.                 arrayOneDim[i] = int.Parse(Console.ReadLine());
  43.             }
  44.  
  45.             Console.WriteLine();
  46.  
  47.             for (int i = 0; i < arrayOneDim.Length; i++)
  48.             {
  49.                 Console.WriteLine(arrayOneDim[i]);
  50.             }
  51.  
  52.             foreach(int number in arrayOneDim)
  53.             {
  54.                 Console.WriteLine(number);
  55.             }
  56.  
  57.             Console.WriteLine();
  58.  
  59.             int[,] arrayMultDim = new int[2, 2];
  60.  
  61.             for (int i = 0; i < arrayMultDim.GetLength(0); i++)
  62.             {
  63.                 for(int j = 0; j < arrayMultDim.GetLength(1); j++)
  64.                 {
  65.                     arrayMultDim[i, j] = int.Parse(Console.ReadLine());
  66.                 }
  67.             }
  68.  
  69.             Console.WriteLine();
  70.  
  71.             for (int i = 0; i < arrayMultDim.GetLength(0); i++)
  72.             {
  73.                 for (int j = 0; j < arrayMultDim.GetLength(1); j++)
  74.                 {
  75.                     Console.Write(arrayMultDim[i, j] + "\t");
  76.                 }
  77.                 Console.Write("\n");
  78.             }
  79.  
  80.             Console.WriteLine();*/
  81.  
  82.             /*int[][] array2 =
  83.             {
  84.                 new int[]{ 0, 2, 4, 5},
  85.                 new int[]{ 1, 2}
  86.             };
  87.  
  88.             for(int i = 0; i < array2.Length; i++)
  89.             {
  90.                 for(int j = 0; j < array2[i].Length; j++)
  91.                 {
  92.                     Console.Write(array2[i][j] + "\t");
  93.                 }
  94.                 Console.Write("\n");
  95.             }
  96.  
  97.             for (int i = 0; i < array2.Length; i++)
  98.             {
  99.                 foreach(int number in array2[i])
  100.                 {
  101.                     Console.Write(number + "\t");
  102.                 }
  103.                 Console.Write("\n");
  104.             }
  105.  
  106.             foreach (int[] array in array2)
  107.             {
  108.                 foreach(int number in array)
  109.                 {
  110.                     Console.Write(number + "\t");
  111.                 }
  112.                 Console.Write("\n");
  113.             }
  114.  
  115.             //Console.WriteLine(array2.Length);*/
  116.         }
  117.  
  118.         static int Sum(params int[] array)
  119.         {
  120.             int sum = 0;
  121.  
  122.             foreach(int n in array)
  123.             {
  124.                 sum += n;
  125.             }
  126.  
  127.             return sum;
  128.         }
  129.  
  130.         static void Change(int[] array)
  131.         {
  132.             array[1] = 10000;
  133.         }
  134.  
  135.         static void Change(string array)
  136.         {
  137.             array = array.Substring(0, array.Length / 2);
  138.         }
  139.     }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement