Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ArrayRotation
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] str = Console.ReadLine().Split();
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string rotation = str[0];
- for (int j = 1; j < str.Length; j++)
- {
- string current = str[j];
- str[j - 1] = current;
- }
- str[str.Length - 1] = rotation;
- }
- Console.WriteLine(string.Join(' ', str));
- }
- }
- }
- Решение с List:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ArrayRotation
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> str = Console.ReadLine().Split().ToList();
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- str.Add(str[0]);
- str.RemoveAt(0);
- }
- Console.WriteLine(string.Join(' ', str));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement