Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string userInput = "";
- int[] array = new int[1];
- int[] tempArray;
- int numeric;
- int sum = 0;
- bool exit = true;
- while (exit)
- {
- userInput = Console.ReadLine();
- if (userInput == "exit")
- {
- exit = false;
- }
- else if (userInput == "sum")
- {
- for (int i = 0; i < array.Length; i++)
- {
- sum += array[i];
- }
- Console.WriteLine(sum);
- sum = 0;
- }
- else
- {
- numeric = Convert.ToInt32(userInput);
- tempArray = new int[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- tempArray[array.Length - 1] = numeric;
- array = tempArray;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement