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;
- using Microsoft.CSharp;
- namespace Order_By_Age
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
- string[] command = Console.ReadLine().Split().ToArray();
- while (command[0] != "end")
- {
- if (command[0] == "swap")
- {
- int index1 = int.Parse(command[1]);
- int index2 = int.Parse(command[2]);
- if ((index1 >= 0 && index1 < numbers.Count) && index2 >= 0 && index2 < numbers.Count)
- {
- int temp = numbers[index1];
- numbers[index1] = numbers[index2];
- numbers[index2] = temp;
- }
- }
- if (command[0] == "multiply")
- {
- int index1 = int.Parse(command[1]);
- int index2 = int.Parse(command[2]);
- if ((index1 >= 0 && index1 < numbers.Count) && index2 >= 0 && index2 < numbers.Count)
- {
- numbers[index1] *= numbers[index2];
- }
- }
- if (command[0] == "decrease")
- {
- for (int i = 0; i < numbers.Count; i++)
- {
- numbers[i] -= 1;
- }
- }
- command = Console.ReadLine().Split().ToArray();
- }
- Console.WriteLine(string.Join(", ", numbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement