C
C#β€’5mo ago
Kapa._

βœ… Sorted Array not Printing

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

namespace A_C_Assignment
{
internal class BubbleSort
{
public static void BubbleAscend(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - 1; j++)
{
if (arr[j] > arr[j+1])
{
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}

Console.ReadKey();
}

public static void BubbleDescend(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - 1; j++)
{
if (arr[j] < arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}

Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A_C_Assignment
{
internal class BubbleSort
{
public static void BubbleAscend(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - 1; j++)
{
if (arr[j] > arr[j+1])
{
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}

Console.ReadKey();
}

public static void BubbleDescend(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - 1; j++)
{
if (arr[j] < arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}

Console.ReadKey();
}
}
}
24 Replies
Kapa._
Kapa._β€’5mo ago
Program Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace A_C_Assignment
{
internal class Program
{
static void Main(string[] args)
{
int[] numbers = { 32867, 8350, 26107, 21308, 8903, 23685, 35401, 36996, 20817, 8485,
31746, 26009, 9002, 8048, 24150, 669, 34754, 20947, 17380, 4524,
14095, 29499, 8856, 21632, 30410, 8265, 29626, 5523, 2195, 12641,
36807, 27758, 11452, 23913, 13129, 7322, 11244, 32139, 4689, 18853,
31937, 39167, 2868, 17662, 16683, 9441, 34607, 36610, 31672, 32951,
38041, 16056, 22680, 18912, 28401, 13096, 9657, 21236, 10431, 39694,
17104, 20165, 14309, 14017, 2973, 20049, 24675, 30573, 38300, 4135,
16483, 4053, rest of the numbers...

Console.WriteLine("Ascending: ");
BubbleSort.BubbleAscend(numbers);
Console.WriteLine(string.Join(",", numbers));


Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace A_C_Assignment
{
internal class Program
{
static void Main(string[] args)
{
int[] numbers = { 32867, 8350, 26107, 21308, 8903, 23685, 35401, 36996, 20817, 8485,
31746, 26009, 9002, 8048, 24150, 669, 34754, 20947, 17380, 4524,
14095, 29499, 8856, 21632, 30410, 8265, 29626, 5523, 2195, 12641,
36807, 27758, 11452, 23913, 13129, 7322, 11244, 32139, 4689, 18853,
31937, 39167, 2868, 17662, 16683, 9441, 34607, 36610, 31672, 32951,
38041, 16056, 22680, 18912, 28401, 13096, 9657, 21236, 10431, 39694,
17104, 20165, 14309, 14017, 2973, 20049, 24675, 30573, 38300, 4135,
16483, 4053, rest of the numbers...

Console.WriteLine("Ascending: ");
BubbleSort.BubbleAscend(numbers);
Console.WriteLine(string.Join(",", numbers));


Console.ReadKey();
}
}
}
Buddy
Buddyβ€’5mo ago
$refvsvalue
Kapa._
Kapa._β€’5mo ago
could you please explain?
Buddy
Buddyβ€’5mo ago
My mistake, it is passed as reference already because it is an array.
Kapa._
Kapa._β€’5mo ago
is it not modified by the bubblesort.bubbleascend? in the sorting class correct?
Buddy
Buddyβ€’5mo ago
Try it and see
Kapa._
Kapa._β€’5mo ago
oki
SparkyCracked
SparkyCrackedβ€’5mo ago
How do we run c# code using the bot?
Buddy
Buddyβ€’5mo ago
!e code here
Kapa._
Kapa._β€’5mo ago
code is still only printing the word "ascending"
Buddy
Buddyβ€’5mo ago
Will you please check if you have any errors?
Kapa._
Kapa._β€’5mo ago
vs says no issues found
Buddy
Buddyβ€’5mo ago
Visual studio has a stupid feature that runs old build if current one fails to build.
Kapa._
Kapa._β€’5mo ago
ive ran it twice still no problems wait i found the problem
Buddy
Buddyβ€’5mo ago
Great!
Kapa._
Kapa._β€’5mo ago
the problem was i had Console.ReadKey(); in the sorting algorithm runs without ref aswell ty for the help brother
MODiX
MODiXβ€’5mo ago
Buddy
My mistake, it is passed as reference already because it is an array.
Quoted by
<@203166497198047232> from #Sorted Array not Printing (click here)
React with ❌ to remove this embed.
Buddy
Buddyβ€’5mo ago
Arrays are reference types, so you don't need to pass it as ref
Kapa._
Kapa._β€’5mo ago
sweet ty how do i close the post?
Buddy
Buddyβ€’5mo ago
$close
MODiX
MODiXβ€’5mo ago
Use the /close command to mark a forum thread as answered
Buddy
Buddyβ€’5mo ago
Just type /close πŸ™‚
Kapa._
Kapa._β€’5mo ago
tyty
Want results from more Discord servers?
Add your server
More Posts
Shitfting Image WPFHello, i'm looking to move an image according to a double value in wpf. In my example it would be toImplementing .net Auth/IdentityI'm having some trouble with implementing .net Identity related features https://paste.mod.gg/kwlujβœ… I get an Issue if I lf 2 artikels. how Ican fix this?```cs double Fleisch = 4.20; double Marmelade = 2.30; double Obst = 2.10; double Multimedia = 12.00;Unable to add migration -So i am having a working ASP.NET application running .NET 8.0. At first everything runs normally butCreating 2 one-to-one relationships with a composite foreign key, EF Code FirstHello everyone, I'm trying to make a database with 2 one-to-one relationships with a composite foreiPop up exe doesn’t run on log inI have a batch login script that runs for all users in my OU. This script runs a Windows Forms app IHow Can I Pull 900K Records From My Database & Not Have The Page Slow Down When Rendering The RecordI have a project that is pulling 900K records from a database & displaying them to a view. Whenever help with shared code between 2 projectsis there a way to have shared code between 2 entirely separate .csprojs? for something like usings oSystem.Data.SQLite command executions slower if a transaction is not explicitly passedI am coping a large amount of data row by row from one table to other. If I initialize a transactionBeginner in EF Core and SQL Server in need for helpHello, I am new here but I needed some help using my project. I need to connect to a SQL Server DB u