Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 22nd, 2007, 09:48 AM
Registered User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Array Intializting problem in QuickSort

I am working on QuickSort Console Application as i made quicksort function

public static void Main(string[] args) { ****************************************
int[] arr;
int hi, lo = 0;
getArray(arr);
Sort(lo, hi,arr);
//The problem lies here it is giving error on variable "hi" as how to determine its the last number in array. *********************************** }
public static void getArray(int [] arr)
{
try {
int i;
for (i = 0; i <= arr.Length; i++)
{
Console.WriteLine("Enter the numbers to sort:" +arr[i]);
}
} catch(Exception e)
{ Console.WriteLine("{0} Exception caught.", e);
}
displayArr(arr);
}
public static void displayArr(int [] arr)
{
for (int i = 0; i <= arr.Length; i++)
{
Console.Write("Sorted:" +arr[i]); } }

Please help me in this. Can any body try to make a small fix to it or explain
Thanks,
regards,

 
Old March 23rd, 2007, 03:43 AM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

int hi, lo = 0;
getArray(arr);
hi = arr.Length - 1;



//www.fformula.net//
 
Old March 23rd, 2007, 04:58 AM
Registered User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a million for reply now i am getting error on
getArray(arr); // its giving error "Use of unassigned local variable arr"

Any solution for that?

Thanks,
Regards

 
Old March 27th, 2007, 09:18 AM
Registered User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This has been sorted out. Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in getting the value of an array knightneo Beginning PHP 0 December 4th, 2006 10:23 PM
Array Problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 3 September 13th, 2006 05:56 AM
Array problem NEO1976 Javascript 0 August 3rd, 2006 03:55 AM
ARRAY PROBLEM??? please help ... mos2128 Visual C++ 1 November 2nd, 2004 01:18 PM
Array Problem - Please help ivanv Classic ASP Basics 1 October 13th, 2003 03:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.