const int throws = 10000000;
DateTime now = DateTime.Now;
Random rand = new Random ((int) now.Millisecond);
int Inside = 0;
for (int i = 0; i < throws; ++i)
{
double cx = rand.NextDouble();
double cy = rand.NextDouble();
double distance = Math.Sqrt ((cx * cx) + (cy * cy));
if (distance < 1.0)
++Inside;
}
double pi = 4 * (double) Inside / (double) throws;
DateTime End = DateTime.Now;
TimeSpan Diff = End - now;
Console.WriteLine ("pi = " + pi);
Console.WriteLine ("Milliseconds = " + Diff.TotalMilliseconds);
Console.ReadLine();
The Lucid Programming Cycle
.NET programiranje i konceptualni dizajn
Saturday, December 13, 2008
Izračunavanje broja Pi
Friday, December 12, 2008
sample code post - DB Broker
public int ObrisiSveZaUslov(IGhost ighost)пример методе DBBroker-a.
{
string upit = "DELETE *" +
" FROM " + ighost.ImeObjekta +
" WHERE " + ighost.UslovZaNalazenjeSlogova;
var komanda = new OleDbCommand(upit, konekcija, transakcija);
try
{
return komanda.ExecuteNonQuery();
}
catch (Exception)
{
throw new Exception("Greska u radu sa bazom! Brisanje po uslovu");
}
}
Wednesday, September 27, 2006
Subscribe to:
Posts (Atom)
http://feeds.feedburner.com/alisteroz