עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

מיון בועות ב-C שארפ

Featured Replies

פורסם
  • מחבר

כשאני מגדיר מראש את המערך בגודל של NumberCount (אחרי שאני קולט את המספר הזה) אני מקבל את השגיאה Index was outside the bounds of the array כשאני מריץ ואגב גם בשיטה הראשונה שעשיתי ומארת לי לכתוב NumberCount-1 ולא NumberCount התוצאה עדיין לא ממוינת טוב.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace T220
{
class Program
{
static void Main(string[] args)
{


//define how many numbers will follow
Console.Write("Enter Numbers Of Numbers For Sorting: ");

//array numbers to read
int NumberCount = int.Parse(Console.ReadLine());

//define array
int[] numbers = new int[NumberCount];


int temp = 0;


//read numbers into array
for (int i = 0; i < NumberCount; i++)
{
int num = int.Parse(Console.ReadLine());
numbers[i] = num;
}
for (int i = 0; i < NumberCount; i++)
{
if (numbers[i] > numbers[i+1])
{
temp = numbers[i];
numbers[i] = numbers[i+1];
numbers[i+1] = temp;
}
}


//print all numbers in ascending order
Console.WriteLine("Bubble Sort Results: ");
for (int i = 0; i < NumberCount; i++)
{
Console.WriteLine(numbers[i]);
}


Console.ReadLine();
}
}
}

פורסם

זה כי לא כתבת את האלגוריתם המלא. קרא את ההודעה של UnsignedInteger.

פורסם
  • מחבר

הצלחתי תודה רבה.

פורסם
  • מחבר

יש לי שאלה קטנה:

בלולאה של האלוגריתם שמסדר את המספרים (מה שהיה לי בהערה) אז עשיתי עם WHILE כאשר count קטן ממספר האיברים שלי שאני צריך למיין, השאלה שלי היא האם עשיתי בסדר ז"א מספר האיברים שלי זה המספר המקסימלי של איטרציות הסידור שיכולות להיות (במקרה הכי גרוע כמובן) ??

פורסם

כן, למרות שיש דרך ליעל יותר (כמות האיברים שצריך לעבור עליהם קטנה מאיטרציה לאיטרציה).

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.