fork(1) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. int[] narabi={1,2,3,4,5};
  8. narabi = erase(narabi,4);
  9. foreach(int a in narabi){
  10. Console.Write(a);
  11. }
  12. }
  13.  
  14. public static int[] erase(int[] arr, int index)
  15. {
  16. if(arr.Length<=index){
  17. return arr;
  18. }
  19.  
  20. int[] result = new int[arr.Length];
  21. bool flg = false;
  22.  
  23. for(int i=0; i<arr.Length-1;i++){
  24. if(i==index){
  25. flg = true;
  26. }
  27. if(flg){
  28. result[i] = arr[i+1];
  29. }else{
  30. result[i] = arr[i];
  31. }
  32. }
  33. result[result.Length-1] = 0;
  34.  
  35. return result;
  36. }
  37. }
Success #stdin #stdout 0.04s 23896KB
stdin
Standard input is empty
stdout
12340