Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Opdracht_1
- {
- class Program
- {
- public static UInt64 a;
- public static UInt64 b;
- public static UInt64 c;
- public static UInt64 Zoeklevel(UInt64 input, UInt64[] levelpoints)
- {
- UInt64 low = 0;
- UInt64 high = (UInt64) levelpoints.Length - 1;
- UInt64 mid = 0;
- while (low < high)
- {
- mid = (low + high) / 2;
- if (input < levelpoints[mid])
- {
- high = mid;
- }
- else
- {
- low = mid + 1;
- }
- }
- return low;
- }
- public static UInt64[] Setup()
- {
- UInt64[] levelspunten = new UInt64[c];
- levelspunten[0] = 0;
- levelspunten[1] = a;
- for (UInt32 i = 2; i < c; i++)
- {
- levelspunten[i] = a + ((a + (b / 2)) / b);
- a = levelspunten[i];
- }
- return levelspunten;
- }
- public static void Run()
- {
- try
- {
- Console.WriteLine("Voer Alfa, Beta en Gamma in. Scheid uw invoer met spaties.");
- string[] invoer1 = Console.ReadLine().Split(' ');
- a = UInt64.Parse(invoer1[0]);
- b = UInt64.Parse(invoer1[1]);
- c = UInt64.Parse(invoer1[2]);
- UInt64[] levels = Program.Setup();
- Console.WriteLine("Correcte invoer. Voer nu het aantal punten in om het bijbehorende level uit te rekenen.");
- foreach (UInt64 k in levels)
- {
- Console.WriteLine(k);
- }
- while (true)
- Console.WriteLine(Zoeklevel(UInt64.Parse(Console.ReadLine()), levels).ToString());
- }
- catch
- {
- Console.WriteLine("Incorrecte invoer. Probeer het opnieuw!");
- Program.Run();
- }
- }
- static void Main()
- {
- Program.Run();
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement