Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CSSix
- {
- class Program
- {
- static void Main(string[] args)
- {
- double Avg;
- double MaxAvg = -1;
- Random Random = new Random();
- double BestNumA=0,BestNumB=0;
- for (int i = 1; i <= 30; ++i)
- {
- double NumA = Random.Next(0, 17);
- double NumB = Random.Next(0, 17);
- Avg= (NumA + NumB) / 2;
- if (Avg > MaxAvg)
- {
- BestNumA = NumA;
- BestNumB = NumB;
- }
- MaxAvg=Math.Max(Avg,MaxAvg);
- Console.WriteLine("{0} {1} Average is {2}", NumA, NumB, Avg);
- }
- Console.WriteLine("The best group has the numbers of {0} and {1}, who result in the biggest average which is {2}", BestNumA, BestNumB, MaxAvg);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment