Advertisement
Guest User

pr 8.2

a guest
Oct 9th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication
  4.  
  5. {
  6.  
  7. class Class
  8.  
  9. {
  10.  
  11. static int [] Input ()
  12.  
  13. {
  14.  
  15. Console.WriteLine("введите размерность массива");
  16.  
  17. int n=int.Parse(Console.ReadLine());
  18.  
  19. int []a=new int[n];
  20.  
  21. for (int i = 0; i < n; ++i)
  22.  
  23. {
  24.  
  25. Console.Write("a[{0}]= ", i);
  26.  
  27. a[i]=int.Parse(Console.ReadLine());
  28.  
  29. }
  30.  
  31. return a;
  32.  
  33. }
  34.  
  35. static int Max(int[] a)
  36.  
  37. {
  38.  
  39. int max=a[0];
  40.  
  41. for (int i = 1; i < a.Length; ++i)
  42.  
  43. if (Math.Abs(a[i]) > max) max=a[i];
  44.  
  45. return max;
  46.  
  47. }
  48.  
  49. static void Main()
  50.  
  51. {
  52.  
  53. int[] myArray=Input();
  54.  
  55. int max=Max(myArray);
  56.  
  57. for (int i=0; i<myArray.Length;++i)
  58.  
  59.  
  60. Console.WriteLine(max);
  61.  
  62. }
  63.  
  64. }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement