Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Side 1
//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> question = new List<string>(); for (int i=0; i<9000; i++) { int tens = Tens(); int hund; double argument = Math.Truncate(Rand.NextD(1.0,99.99)*tens)/tens; double num1 = argument; if (tens==100) { hund = 10; } else hund = 100; double num2 = Math.Truncate(Rand.NextD(2,hund)*hund)/hund; double result = num1*num2; //Console.WriteLine(count); if(Math.Floor(num1)!=num1 && question.Count()<120) { Console.WriteLine("{0}\\times{1}={2}", num1,num2, result); //question.Add(num1+"/"+num1+"="+result); } } //Console.WriteLine(question.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
Find duplicated values in a list
Cenforce 100 mg
reverse a stack
My name
sdfghuyhtgrfedwsx
Ccc
BNV
Daimone
Swap w/o third var
Extension Methods (edited)