Реших задачата обаче judge ми дава 80/100 точки,къде мие проблема немога да го открия?Ето и задачата,помогнете ми моля?
Write a program that receives an array and number of rotations you have to perform (first element goes at the end) Print the resulting array.
Examples
Input |
Output |
51 47 32 61 21 2 |
32 61 21 51 47 |
32 21 61 1 4 |
32 21 61 1 |
2 4 15 31 5 |
4 15 31 2
|
using System;
using System.Linq;
namespace _04.ArrayRotation
{
class Program
{
static void Main(string[] args)
{
int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
int rotation = int.Parse(Console.ReadLine());
int[] input = new int[array.Length];
for (int i = 0; i < rotation; i++)
{
int firstElement = array[0];
for (int j = 0; j <array.Length-1; j++)
{
input[j] = array[j + 1];
}
input[array.Length - 1] = firstElement;
for (int k = 0; k < array.Length; k++)
{
array[k] = 0;
array[k] = input[k];
}
}
Console.WriteLine(string.Join(" ",input));
}
}
}
Thank you.
Благодаря.