add csharp examples (#10)
This commit is contained in:
committed by
Aditya Bhargava
parent
c3396b8b0a
commit
62ed616954
2
02_selection_sort/csharp/01_selection_sort/.gitignore
vendored
Normal file
2
02_selection_sort/csharp/01_selection_sort/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
**/bin/*
|
||||
**/obj/*
|
||||
23
02_selection_sort/csharp/01_selection_sort/.vscode/launch.json
vendored
Normal file
23
02_selection_sort/csharp/01_selection_sort/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/csharp.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"externalConsole": false,
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command.pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
||||
16
02_selection_sort/csharp/01_selection_sort/.vscode/tasks.json
vendored
Normal file
16
02_selection_sort/csharp/01_selection_sort/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"command": "dotnet",
|
||||
"isShellCommand": true,
|
||||
"args": [],
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "build",
|
||||
"args": [
|
||||
"${workspaceRoot}/project.json"
|
||||
],
|
||||
"isBuildCommand": true,
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
41
02_selection_sort/csharp/01_selection_sort/Program.cs
Normal file
41
02_selection_sort/csharp/01_selection_sort/Program.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var arr = new List<int> { 5, 3, 6, 2, 10 };
|
||||
Console.WriteLine(string.Join(", ", SelectionSort(arr)));
|
||||
}
|
||||
|
||||
private static int[] SelectionSort(List<int> arr)
|
||||
{
|
||||
var newArr = new int[arr.Count];
|
||||
for (int i = 0; i < newArr.Length; i++)
|
||||
{
|
||||
var smallest = FindSmallest(arr);
|
||||
newArr[i] = arr[smallest];
|
||||
arr.RemoveAt(smallest);
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
|
||||
private static int FindSmallest(List<int> arr)
|
||||
{
|
||||
var smallest = arr[0];
|
||||
var smallestIndex = 0;
|
||||
for (int i = 0; i < arr.Count; i++)
|
||||
{
|
||||
if (arr[i] < smallest)
|
||||
{
|
||||
smallest = arr[i];
|
||||
smallestIndex = i;
|
||||
}
|
||||
}
|
||||
return smallestIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
02_selection_sort/csharp/01_selection_sort/project.json
Normal file
19
02_selection_sort/csharp/01_selection_sort/project.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"buildOptions": {
|
||||
"debugType": "portable",
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.1"
|
||||
}
|
||||
},
|
||||
"imports": "dnxcore50"
|
||||
}
|
||||
}
|
||||
}
|
||||
6598
02_selection_sort/csharp/01_selection_sort/project.lock.json
Normal file
6598
02_selection_sort/csharp/01_selection_sort/project.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user