Guest User

Untitled

a guest
Mar 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp2
  8. {
  9. class Program
  10. {
  11.  
  12. static double GetAvarage(int[] numbers)
  13. {
  14. int total = 0;
  15. for (int i = 0; i < numbers.Length; i++)
  16. {
  17. total += numbers[i];
  18. }
  19.  
  20. return total / numbers.Length;
  21. }
  22.  
  23. static int GetMinimum(int[] numbers)
  24. {
  25. int min = numbers[0];
  26. for (int i = 0; i < numbers.Length; i++)
  27. {
  28. if (min > numbers[i]) {
  29. min = numbers[i];
  30. }
  31. }
  32.  
  33. return min;
  34. }
  35.  
  36. static double GetMaximum(int[] numbers)
  37. {
  38. int max = numbers[0];
  39. for (int i = 0; i < numbers.Length; i++)
  40. {
  41. if (max < numbers[i]) {
  42. max = numbers[i];
  43. }
  44. }
  45.  
  46. return max;
  47. }
  48.  
  49. static void Main(string[] args)
  50. {
  51. //turim amziaus masyva
  52. //isspausdinam amzius i ekrana
  53. //ir gale programos isspausdiname amziaus vidurki
  54. // min ir max
  55.  
  56. int[] ages = { 90, 80, 30, 45, 50 };
  57.  
  58. Console.WriteLine("Amziai:");
  59. foreach (int age in ages)
  60. {
  61. Console.WriteLine(age);
  62. }
  63.  
  64. Console.WriteLine("Amziu vidurkis: {0}", GetAvarage(ages));
  65. Console.WriteLine("Seniausiam zmogui yra {0} metu, jauniausiam yra {1} metu", GetMaximum(ages), GetMinimum(ages));
  66. Console.ReadKey();
  67. }
  68.  
  69. }
  70. }
Add Comment
Please, Sign In to add comment