-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SCRIPTS = $(wildcard **/*.cs) | ||
|
||
BINARIES = $(SCRIPTS:%.cs=%-csc.exe) \ | ||
$(SCRIPTS:%.cs=%-mcs.exe) | ||
|
||
%-csc.exe: %.cs | ||
mono-csc $< -out:$@ | ||
|
||
%-mcs.exe: %.cs | ||
mcs $< -out:$@ | ||
|
||
all: $(BINARIES) | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
rm -f $(BINARIES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
title: 'C#' | ||
|
||
strategy: | ||
matrix: | ||
command: | ||
- title: 'csc' | ||
command: 'mono %s-csc.exe' | ||
|
||
- title: 'mcs' | ||
command: 'mono %s-mcs.exe' | ||
|
||
files: | ||
- mandelbrot/Simple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
var startTime = DateTime.Now; | ||
|
||
Index(); | ||
|
||
var endTime = DateTime.Now; | ||
var duration = endTime - startTime; | ||
Console.WriteLine("Execution time: " + duration.TotalMilliseconds + "ms"); | ||
} | ||
|
||
static void Index() | ||
{ | ||
for (int y = -39; y < 39; y++) | ||
{ | ||
Console.WriteLine(); | ||
|
||
for (int x = -39; x < 39; x++) | ||
{ | ||
int i = Mandelbrot(x / 40.0, y / 40.0); | ||
|
||
if (i == 0) | ||
{ | ||
Console.Write("*"); | ||
} | ||
else | ||
{ | ||
Console.Write(" "); | ||
} | ||
} | ||
} | ||
|
||
Console.WriteLine(); | ||
} | ||
|
||
static int Mandelbrot(double x, double y) | ||
{ | ||
double cr = y - 0.5; | ||
double ci = x; | ||
double zi = 0.0; | ||
double zr = 0.0; | ||
int i = 0; | ||
|
||
while (true) | ||
{ | ||
i++; | ||
|
||
double temp = zr * zi; | ||
|
||
double zr2 = zr * zr; | ||
double zi2 = zi * zi; | ||
|
||
zr = zr2 - zi2 + cr; | ||
zi = temp + temp + ci; | ||
|
||
if (zi2 + zr2 > 16) | ||
{ | ||
return i; | ||
} | ||
|
||
if (i > 5000) | ||
{ | ||
return 0; | ||
} | ||
} | ||
} | ||
} |