Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 753 results for
selectionsort
- Page 1
Re: SelectionSort
Programming
Software Development
15 Years Ago
by Dewey1040
… [code=C] #include <stdio.h> void
SelectionSort
( int A[], int n ); int main(int argc, char…&A[i]) == 1; ++i) size = i - 2;
SelectionSort
( A, size ); printf("\nFirst five numbers:\n"); for…d", A[i]); fclose(fin); return 0; } void
SelectionSort
( int A[], int n ){ int i, j, min_index, temp…
Re: SelectionSort
Programming
Software Development
15 Years Ago
by Dewey1040
… code. [code=C] #include <stdio.h> void
SelectionSort
( int A[], int n ); int main(int argc, char *…(fin, "%d", &A[j]) == 1; j++)
SelectionSort
( A, j + 1 ); printf("\nFirst five numbers:\n"…;%d, ", A[i]); fclose(fin); return 0; } void
SelectionSort
( int A[], int n ){ int i, j, min_index, temp; …
SelectionSort
Programming
Software Development
15 Years Ago
by Dewey1040
I understand the algorithm
SelectionSort
, but once again my problem is the easy part( i …? I thought i did it right but when i run
selectionsort
it prints out from A[0] to A[100000] when…
Re: SelectionSort
Programming
Software Development
15 Years Ago
by ArkM
Through overboard your snippet. [code=c] int n; /* elements counter */ ... for (n = 0; fscanf(fin,"%d",&A[n])==1; ++n) ; [/code] ;)
Re: SelectionSort
Programming
Software Development
15 Years Ago
by ArkM
It turned out that you can't copy/paste two lines of code from my post (and don't understand simplest C constructs). Look at your "improvement": [code=c] for (i = 0; fscanf(fin, "%d", &A[i]) == 1; ++i) size = i - 2; /* instead of */ for (n = 0; fscanf(fin,"%d",&A[n])==1; ++n) ; [/code] …
Re: SelectionSort
Programming
Software Development
15 Years Ago
by ArkM
Yet another free advice: don't declare (very) large arrays as automatic (local, as usually allocated on the program stack). Better use malloc and don't forget to free obtained pointers: [code=c] #define HUGE_SIZE 1000000 ... int* arr = malloc(sizeof(*arr)*HUGE_SIZE); ... arr[i] - same code as for array free(arr); [/code] It's impossible to …
Filling an array from Class and sort the array by selectionsort
Programming
Software Development
16 Years Ago
by Tinemelk
…, and then sort the elements by using the
selectionsort
algoritm. Im guessing I have to replace my filling… like Cars<int>Cars[10]? [CODE]void
selectionSort
(int *tab, int antall){ int indexLargestSoFar; int temp;…cout<<"Sorterer tabellen....." <<endl;
selectionSort
(tab,tab_length); for(int i = 0; i < 10…
Re: Filling an array from Class and sort the array by selectionsort
Programming
Software Development
16 Years Ago
by Ancient Dragon
>>give me a clue what to do next.. like replacing [URL="http://www.gidnetwork.com/b-66.html"]void main() with int main()[/URL] ?
Re: Filling an array from Class and sort the array by selectionsort
Programming
Software Development
16 Years Ago
by Tinemelk
[QUOTE=Ancient Dragon;546282]>>give me a clue what to do next.. like replacing [URL="http://www.gidnetwork.com/b-66.html"]void main() with int main()[/URL] ?[/QUOTE] howcome? I thougth void main only reveals me from writing return 0; in the bottom? that wouldn't have any effect ..... . .. ..... .
Re: Filling an array from Class and sort the array by selectionsort
Programming
Software Development
16 Years Ago
by Ancient Dragon
>>howcome? CLICK THE LINK. *Sigh*
Re: Filling an array from Class and sort the array by selectionsort
Programming
Software Development
16 Years Ago
by Tinemelk
[QUOTE=Ancient Dragon;546294]>>howcome? CLICK THE LINK. *Sigh*[/QUOTE] sorry, Ididn't understand that:P but fine, I could always replace void main with int main. I usually use Int main anyway, but my program workes just fine, I just need some guidelines for how to fill the tab with elements from my class instead of random numbers …
Re: Filling an array from Class and sort the array by selectionsort
Programming
Software Development
16 Years Ago
by Ancient Dragon
I have no ideas how to do that eiher because you didn't post the code for that class or how it is instantiated. Don't ask me to read a different thread because I won't. Each thread must be self-sufficient.
Re: Filling an array from Class and sort the array by selectionsort
Programming
Software Development
16 Years Ago
by Tinemelk
[QUOTE=Ancient Dragon;546299]I have no ideas how to do that eiher because you didn't post the code for that class or how it is instantiated. Don't ask me to read a different thread because I won't. Each thread must be self-sufficient.[/QUOTE] well sorry about that. I smply wanted a guideline, not a complete eksample therefore I didn't post …
Re: Filling an array from Class and sort the array by selectionsort
Programming
Software Development
16 Years Ago
by Ancient Dragon
There is no one way to accomplish what you want to do. Each program is unique. Without knowing what cars.h looks like its impossible for anyone to tell you how to use an array of car classes for the data you need.
Re: need help with this code
Programming
Software Development
15 Years Ago
by ddanbe
Selectionsort
looks more like a bubblesort to me. The swap? in your if-statement should be in braces{} I would declare my variables out of the for-loop. What is temp doing?
Help with Selection Sort for vectors and arrays
Programming
Software Development
10 Years Ago
by asundar
…vector <int>&>(smallVector,smallVector.size());
SelectionSort
sort; sort.sortDataIter(smallArray,smallSize); cout << …{ min = j; } } swap(theList[i],theList[min]); } } void
SelectionSort
:: sortDataIter (vector<int>& theList, int sizeOfList) { int…
Re: Problem converting Selection Sort to Class
Programming
Software Development
18 Years Ago
by Bench
… a constructor which accepts a range of values - eg, [INLINECODE]
Selectionsort
::
Selectionsort
(int* begin, int* end) [/INLINECODE] or one which accepts an… array, eg, [INLINECODE]
Selectionsort
::
Selectionsort
(int arr[]) [/INLINECODE] Whichever of these you use, I don…
Problem converting Selection Sort to Class
Programming
Software Development
18 Years Ago
by Lomas
…include <iostream> using namespace std; class
Selectionsort
{ private: int i, j; int numbers[]; int…public: void sort(int[], int); void print(); }; void
Selectionsort
::sort(int numbers[], int array_size) { for (i =…
{Urgent} need help with file compression and decompression
Programming
Software Development
16 Years Ago
by j2swift
…++count_array[charPosition][nextPosition]; ++sort_array[charPosition][nextPosition]; }
selectionSort
(sort_array, indexSize); //**TEST for(int x=0;… ++count_array[charPosition][nextPosition]; ++sort_array[charPosition][nextPosition]; }
selectionSort
(sort_array, indexSize); //Display frequency //option to display …
Re: C++ newbie Need help^_^
Programming
Software Development
14 Years Ago
by Lerner
… fileName that's been sent to
selectionSort
that is being used fileName1 in
selectionSort
until you overwrite it on line… 114. Since you are using an ofstream in
selectionSort
and fileName1 is the string declared to hold the …to, I suspect you really want to send fileName1 to
selectionSort
, not fileName, anyway, which would be another good …
How many loops
Programming
Software Development
16 Years Ago
by helixkod
… while (swap); count++; return count; } //********************************************************************* //
selectionSort
takes in the array numbers and sorts the numbers from…to sort the numbers. * //********************************************************************* int
selectionSort
(int array[], int size) { int…
add selection sort as function in code
Programming
Software Development
14 Years Ago
by NitaB
…<< endl; } } //**************************************************************************** void
selectionSort
(size_t allCount[],size_t Size) { for (int …<< endl; } } //**************************************************************************** void
selectionSort
(size_t allCount[],size_t Size) { for (int …
[HELP] Converting my java code to GUI code
Programming
Software Development
11 Years Ago
by gm.rupert
….print("The Sorted numbers: "); access.
SelectionSort
(x); } } //
selectionSort
class public class
SelectionSort
{ public void
SelectionSort
(int[] arr){ for(int i=0; i…
Re: Help with Selection Sort for vectors and arrays
Programming
Software Development
10 Years Ago
by tinstaafl
Your algorithms seem to be ok, the problem appears to be in the swap. You're only swapping the values not the elements of the collection itself. See if this helps: void
SelectionSort
:: swap(int& one, int& two) { int temp = one; one = two; two = temp; }
Question Reading from a file and inputting into a string array I am getting a errors.
Programming
Software Development
16 Years Ago
by dpfaff
…inlab.dat, array, MAXSIZE); print (array, MAXSIZE); printNewLines(3);
selectionSort
(array, MAXSIZE); print (array, MAXSIZE); inlab.dat.close(); return… 0; } void
selectionSort
(String array[], int size) { int start, minIndex, minValue; for…
Help with minor corrections for selection sort and binary search
Programming
Software Development
14 Years Ago
by trace63b
…Student Names - Unsorted", JOptionPane.PLAIN_MESSAGE); //Call for
selectionSort
method
selectionSort
(studentNames, NO_OF_STUDENTS); //Display dialog box with sorted array …could not figure out how to correct public static void
selectionSort
(String studentNames[],int NO_OF_STUDENTS) { int index; int …
C++ newbie Need help^_^
Programming
Software Development
14 Years Ago
by 07tr0wa07
… prototype int binarySearch(long aray[], int, int); //function prototype void
selectionSort
(ofstream & , char[] , long aray[], int); //Fuction prototype void showarray… >> singleary; } //display the sorted numbers to the outfile
selectionSort
(outfile, fileName, aray,loop); //display unsorted array showarray(aray, loop…
Help with Average Class: arrays
Programming
Software Development
14 Years Ago
by bustersox
…quot;); data[index] = keyboard.nextInt(); // Call the
selectionSort
method.
selectionSort
(); // Call the calculateMean method. calculateMean(); } } /**…data The array to sort. */ public void
selectionSort
() { int startScan, index, minIndex, minValue;…
program help
Programming
Software Development
12 Years Ago
by broodwich
…, 6545231, 3852085, 7576651, 7881200, 4581002 }; int accountNumber;
selectionSort
(accounts, SIZE); cout << "\nPlease enter a…." << endl; return 0; } void
selectionSort
(int array[], int size) { int startScan, minIndex, minValue…
Radix sort
Programming
Software Development
11 Years Ago
by aaal
… = "BubbleSort"; break; case 'S': f = &
selectionSort
; algstr = "
SelectionSort
"; break; //case 'Q': f = &quickSort; algstr =… = "BubbleSort"; break; case 'S': f = &
selectionSort
; algstr = "
SelectionSort
"; break; //case 'I': f = &insertionSort; algstr =…
1
2
3
13
Next
Last
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Forums
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC