Jump to content
Due to limited holiday staffing, chat will be unavailable from Thursday, July 2 at 5:30 PM (CDT) to Monday, July 13 at 8 AM (CDT). This will allow us to reply to your email requests as quickly as possible. Thank you for understanding. ×

Search the Community

Showing results for tags 'example'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Calendars

There are no results to display.

There are no results to display.

Forums

  • General Discussion
    • Community Announcements
    • Evernote General Discussions
    • Evernote Integrations
    • Evernote API Discussion
  • Evernote Betas
    • Public Betas
  • FAQ's: Best Answers
    • FAQ's: Best Answers
  • Evernote Business
    • Evernote Business Technical Issues
    • Evernote Business Requests
  • Possible Bugs/Technical Issues
    • General Technical Issues
    • Evernote for Android Issues
    • Evernote for iOS Issues
    • Evernote for Mac Issues
    • Evernote for Windows Issues
    • Web Client Issues
    • Evernote Product Suite Issues
  • Product Feedback/Feature Requests
    • General Feature Requests
    • Evernote for Android Requests
    • Evernote for iOS Requests
    • Evernote for Mac Requests
    • Evernote Web Client Requests
    • Evernote for Windows Requests
    • Evernote Product Suite Requests
  • Foro de discusión de Evernote
    • Anuncios Comunitarios
    • Discusión General
    • Posibles Defectos/Problemas Técnicos
    • Solicitud de Funciones
  • International Forums
    • Japanese Discussions
    • Brazilian Portuguese Discussions
    • Korean Discussions
    • Traditional Chinese Discussions
  • Evernote Forum Archives
  • Web Clipper***

Blogs

There are no results to display.

There are no results to display.

Categories

There are no results to display.

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Subscription

Found 1 result

  1. Hi! I create this topic just for C# example of sorting and search algorithms. For your information I'm just a student. I'm from Sweden, so I write in swedish in WriteLine. I hope that you enjoy! static void Main(string[] args) { while (true) { //Creates an Array with value 100 int[] myArray = new int[100]; //Creates randomizer to make random numbers Random randomizer = new Random(); for (int i = 0; i < myArray.Length; i++) { myArray = randomizer.Next(1000); } //May choose among various sorting algorithms for sorting number (for example Bubble sort) SelectionSort(myArray); //Makes it "fancier" Console.Write("{ "); for (int i = 0; i < myArray.Length; i++) { Console.Write(myArray); if (i < myArray.Length - 1) { Console.Write(", "); } } Console.Write(" }\n"); Console.Write("Mata in talet som du vill hitta: "); int searchNumber = int.Parse(Console.ReadLine()); //Choose between Linear and Binary search: int pos = LinearSearch(searchNumber, myArray); if (pos == -1) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Talet finns inte.\nTryck 'ENTER' för att försöka igen."); } else { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Talet finns på position: "+ pos); } Console.ReadLine(); } } //Here is four methods for example (two sorting and two search algorithms) private static void SelectionSort(int[] myArray) { //Going through all non-sorted elements and find the smallest for (int i = 0; i < myArray.Length; i++) { //Assume that the first unsorted position contains the smallest value int minPos = i; for (int j = i; j < i; j++) { //If we find a smaller element, update minPos if (myArray[j] < myArray[minPos]) { minPos = j; } } //byt plats int tmp = myArray; myArray = myArray[minPos]; myArray[minPos] = tmp; } } private static void BubbleSort(int[] myArray) { for (int i = myArray.Length - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (myArray[j] > myArray[j + 1]) { int tmp = myArray[j]; myArray[j] = myArray[j + 1]; myArray[j + 1] = tmp; } } } } private static int BinarySearch(int searchNumber, int[] myArray) { int min = 0; int max = myArray.Length - 1; while (min < max) { int mid = (min + max) / 2; if (searchNumber == myArray[mid]) { return mid; } else if (searchNumber < myArray[mid]) { max = mid - 1; } else { min = mid + 1; } } return -1; } private static int LinearSearch(int searchNumber, int[] searchArray) { int position = -1; for (int i = 0; i < searchArray.Length; i++) { if (searchNumber == searchArray) { position = i; break; } } return position; }
×
×
  • Create New...