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 lesson5_potok4
- {
- class Program
- {
- static void Main(string[] args)
- {
- var array = new[] { 1, 2, 3 };
- Console.WriteLine(Sum(array));
- /*int[] array = new int[4] { 1, 2, 3, 4};
- int[] array2 = new int[4];
- for (int i = 0; i < array.Length; i++)
- {
- array2[i] = array[i];
- }
- foreach(int n in array)
- {
- Console.WriteLine(n);
- }
- Change(array2);
- Console.WriteLine();
- foreach (int n in array)
- {
- Console.WriteLine(n);
- }
- /*int[] arrayOneDim = new int[4];
- for(int i = 0; i < arrayOneDim.Length; i++)
- {
- arrayOneDim[i] = int.Parse(Console.ReadLine());
- }
- Console.WriteLine();
- for (int i = 0; i < arrayOneDim.Length; i++)
- {
- Console.WriteLine(arrayOneDim[i]);
- }
- foreach(int number in arrayOneDim)
- {
- Console.WriteLine(number);
- }
- Console.WriteLine();
- int[,] arrayMultDim = new int[2, 2];
- for (int i = 0; i < arrayMultDim.GetLength(0); i++)
- {
- for(int j = 0; j < arrayMultDim.GetLength(1); j++)
- {
- arrayMultDim[i, j] = int.Parse(Console.ReadLine());
- }
- }
- Console.WriteLine();
- for (int i = 0; i < arrayMultDim.GetLength(0); i++)
- {
- for (int j = 0; j < arrayMultDim.GetLength(1); j++)
- {
- Console.Write(arrayMultDim[i, j] + "\t");
- }
- Console.Write("\n");
- }
- Console.WriteLine();*/
- /*int[][] array2 =
- {
- new int[]{ 0, 2, 4, 5},
- new int[]{ 1, 2}
- };
- for(int i = 0; i < array2.Length; i++)
- {
- for(int j = 0; j < array2[i].Length; j++)
- {
- Console.Write(array2[i][j] + "\t");
- }
- Console.Write("\n");
- }
- for (int i = 0; i < array2.Length; i++)
- {
- foreach(int number in array2[i])
- {
- Console.Write(number + "\t");
- }
- Console.Write("\n");
- }
- foreach (int[] array in array2)
- {
- foreach(int number in array)
- {
- Console.Write(number + "\t");
- }
- Console.Write("\n");
- }
- //Console.WriteLine(array2.Length);*/
- }
- static int Sum(params int[] array)
- {
- int sum = 0;
- foreach(int n in array)
- {
- sum += n;
- }
- return sum;
- }
- static void Change(int[] array)
- {
- array[1] = 10000;
- }
- static void Change(string array)
- {
- array = array.Substring(0, array.Length / 2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement