Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
uniqueness
//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; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Random rand = new Random(); HashSet<string> divQ = new HashSet<string>(); /*for (int i=2; i<=100; i++) { for (int j=2; j<=10; j++) { if (i%j==0&& i/j<=10) { string a = Convert.ToString(i)+"\\div"+Convert.ToString(j); divQ.Add(a); } } }*/ int count = 0; List<int> divisor = new List<int>(); List<int> quotient = new List<int>(); while (divQ.Count()<90) { int a = rand.Next(2,101); int b = rand.Next(2,11); int c = a/b; if (a%b==0 && a/b<=10) { if (quotient.Count()==0) { string q = Convert.ToString(a)+"\\div"+Convert.ToString(b)+"= "+Convert.ToString(a/b); divQ.Add(q); count++; } else if (quotient.Count()==1 && !quotient[count].Equals(quotient[count-1])) { // if [count] and [count-1] not equal string q = Convert.ToString(a)+"\\div"+Convert.ToString(b)+"= "+Convert.ToString(a/b); divQ.Add(q); count++; } else if (quotient.Count()==2 && ) } } /* for (int i =0; i<100; i++) { list.Add(rand.Next(1,40)); }*/ foreach (var item in divQ) { //Console.WriteLine(item); } } public static bool Unique(List<int> t){ int count = 0; for (int i=0; i<t.Count()-1; i++){ for (int j=i+1; j<t.Count(); j++) { //Console.WriteLine(i + " " + j); if (!t[i].Equals(t[j])){ count++; } } } if (count.Equals(nCr(t.Count(),2))) { return true; } else return false; } public static int nCr(int n, int r) { return (Factorial(n)/Factorial(r))/Factorial(n-r); } public static int Factorial(int n) { if (n>0) { for (int i=n-1; i>1; i--) { n = n*i; } return n; } else if (n<0) throw new ArgumentOutOfRangeException("n","n should be non-zero"); else return 1; } } }
run
|
edit
|
history
|
help
0
split string
Convert string to unicode representation
test1.m
Hi
Sri 19 Sept
zmeika
sortowania przez wstawienie Correct
world
Random number between IF Values
test type casting