Advertisement
Guest User

Untitled

a guest
Jul 11th, 2019
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 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 Min_Max_Sum_Average
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. short n = short.Parse(Console.ReadLine());
  14.  
  15. double min = double.MaxValue;
  16. double max = double.MinValue;
  17. double sum = 0;
  18. double avg = 0;
  19.  
  20.  
  21.  
  22. for (int i = 0; i < n; i++)
  23. {
  24. double b = double.Parse(Console.ReadLine());
  25.  
  26. if (b > max)
  27. {
  28. max = b;
  29. }
  30. if (b < min)
  31. {
  32. min = b;
  33. }
  34. sum += b;
  35. }
  36.  
  37. avg = sum / n;
  38.  
  39.  
  40. Console.WriteLine("min={0:f2}",min);
  41. Console.WriteLine("max={0:f2}",max);
  42. Console.WriteLine("sum={0:f2}",sum);
  43. Console.WriteLine("avg={0:f2}",avg);
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement