+ 2
What is wrong with this code, this code is giving the compilation error?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int[] arr={1,2,3,4,5,6}; Console.Write("Enter number to shift the array: "); int d=int.Parse(Console.ReadLine()); for(int i=0;i<d;i++) { int temp=arr[0]; for(int j=0;j<arr.Length-1;j++) { arr[j]=arr[j+1]; } arr[arr.Length-1]=temp; } Console.ReadLine(); } } }
5 ответов
+ 1
sai he
+ 1
There is nothing wrong with this code.
It works fine.
If sololearn does have problems with its internet connection you sometime get a compilation error as result although the code is fine.
You also can get a compilation error if the loop takes to much time to run.
I used 3 as input.
In sololearn I removed the last //Console.ReadLine because you do not need it on sololearn.
And I added a output-loop so I can prove the array was shifted.
https://code.sololearn.com/cCKvpNd33x4L
0
Syed Waleed ??
0
djAna💕💞💓 ??
0
but compilation error occurs...?