Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LCG
- {
- static void Main()
- {
- Console.Write("Enter Initial SEED : 0x"); // 初期SEED入力
- if (uint.TryParse(Console.ReadLine(), System.Globalization.NumberStyles.HexNumber, null, out uint Seed))
- {
- Console.Write("Enter SEED Count :");
- if (int.TryParse(Console.ReadLine(), out int count) && count > 0)
- {
- Console.Write("Enter File Name :");
- string outputPath = Console.ReadLine();
- if (!outputPath.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
- {
- outputPath += ".txt";
- }
- using (StreamWriter writer = new(outputPath))
- {
- for (int i = 1; i < count; i++, Seed = NextSeed(Seed))
- {
- Console.WriteLine($"Count:{count}, Seed:{Seed:X8}");
- writer.WriteLine($"Count:{count}, Seed:{Seed:X8}");
- }
- Console.WriteLine($"Generated {count} seeds. Output saved to {outputPath}");
- }
- }
- else { Console.WriteLine("Invalid Input for SEED Count."); }
- }
- else { Console.WriteLine("Invalid Input for Initial SEED."); }
- }
- static uint NextSeed(uint Seed)
- {
- uint a = 1103515245;
- uint b = 12345;
- return (a * Seed + b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment