Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Side1-2
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Threading; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here List<string> divQ = new List<string>(); for (int k=0; k<2000; k++){ for (int i=0; i<6500; i++) { int tens = Tens(); double argument = Math.Truncate(Rand.NextD(1.0,99.99)*tens)/tens; decimal num1 = Convert.ToDecimal(argument); int dividend = Rand.Next(2,1000); decimal result = dividend/num1; int count = BitConverter.GetBytes(decimal.GetBits(result)[3])[2]; //Console.WriteLine(count); if(count<4 && divQ.Count()<120) { //Console.WriteLine("{0}/{1}={2}", dividend,num1, dividend/num1); divQ.Add(dividend+"\\div"+num1+"="); } } Console.WriteLine(divQ.Count()); } /* for (int i=0; i<100; i++){ int a = Tens(); Console.WriteLine(Tens()+" "+ Tens()); }*/ } public static int Tens(){ int rand = Rand.Next(0,2); if (rand==0) { return 10; } else return 100; } public static class Rand { /// <summary> /// Random number generator used to generate seeds, /// which are then used to create new random number /// generators on a per-thread basis. /// </summary> private static readonly Random globalRandom = new Random(); private static readonly object globalLock = new object(); /// <summary> /// Random number generator /// </summary> private static readonly ThreadLocal<Random> threadRandom = new ThreadLocal<Random>(NewRandom); /// <summary> /// Creates a new instance of Random. The seed is derived /// from a global (static) instance of Random, rather /// than time. /// </summary> public static Random NewRandom() { lock (globalLock) { return new Random(globalRandom.Next()); } } /// <summary> /// Returns an instance of Random which can be used freely /// within the current thread. /// </summary> public static Random Instance { get { return threadRandom.Value; } } /// <summary>See <see cref="Random.Next()" /></summary> public static int Next() { return Instance.Next(); } /// <summary>See <see cref="Random.Next(int)" /></summary> public static int Next(int maxValue) { return Instance.Next(maxValue); } /// <summary>See <see cref="Random.Next(int, int)" /></summary> public static int Next(int minValue, int maxValue) { return Instance.Next(minValue, maxValue); } /// <summary>See <see cref="Random.NextDouble()" /></summary> public static double NextDouble() { return Instance.NextDouble(); } /// <summary>See <see cref="Random.NextBytes(byte[])" /></summary> public static void NextBytes(byte[] buffer) { Instance.NextBytes(buffer); } public static double NextD(double minValue, double maxValue) { return Instance.NextDouble()*(maxValue-minValue)+minValue; } } } }
run
|
edit
|
history
|
help
0
C# Basic learning
Punnet Square Generator
Date Diff
bitcount algo
Sandeep Chandra Bose
bubble sort
tst
ShortBubbleSort
Base
Pending Finalizer