using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
class Permutation
{
private void swap(ref char a, ref char b)
{
if (a == b) return;
a ^= b;
b ^= a;
a ^= b;
}
public void setper(char[] list)
{
int x = list.Length - 1;
go(list, 0, x);
}
private void go(char[] list, int k, int m)
{
int i;
if (k == m)
{
Console.Write(list);
Console.WriteLine(" ");
}
else
for (i = k; i <= m; i++)
{
swap(ref list[k], ref list[i]);
go(list, k + 1, m);
swap(ref list[k], ref list[i]);
}
Console.ReadLine();
}
}
class Class1
{
static void Main()
{
Permutation p = new Permutation();
string c = "123456";
char[] c2 = c.ToCharArray();
p.setper(c2);
}
}
}
Minggu, 26 Mei 2013
Console Random Number 1-6...!!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RandomNumber
{
class Program
{
static void Main()
{
Random();
Random();
Random();
Random();
Random();
Random();
}
static Random MyRandom = new Random();
static void R()
{
for(int i = 0; i < 600; i++)
{
double value;
double n = 0.5 + MyRandom.NextDouble() * 6.0-0.5;
value = Math.Round(n);
Console.WriteLine(value);
}
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RandomNumber
{
class Program
{
static void Main()
{
Random();
Random();
Random();
Random();
Random();
Random();
}
static Random MyRandom = new Random();
static void R()
{
for(int i = 0; i < 600; i++)
{
double value;
double n = 0.5 + MyRandom.NextDouble() * 6.0-0.5;
value = Math.Round(n);
Console.WriteLine(value);
}
Console.ReadLine();
}
}
}
Langganan:
Komentar (Atom)