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 Home6
- {
- class Program
- {
- static void Main(string[] args)
- {
- string message = " ";
- bool isSum = false;
- int arraySum = 0;
- int[] array = new int[0];
- do
- {
- message = Console.ReadLine();
- switch (message)
- {
- case "sum":
- for (int i = 0; i < array.Length; i++)
- {
- arraySum += array[i];
- }
- isSum = true;
- break;
- default:
- int[] tempArray = new int[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- tempArray[tempArray.Length-1] = Convert.ToInt32(message);
- array = tempArray;
- break;
- }
- } while (isSum != true);
- Console.WriteLine(arraySum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement