myGully.com Boerse.SH - BOERSE.AM - BOERSE.IO - BOERSE.IM Boerse.BZ .TO Nachfolger
Zurück   myGully.com > Computer & Technik > Programmierung
Seite neu laden

Programm C# Zahlen sortieren

Willkommen

myGully

Links

Forum

 
 
 
Themen-Optionen Ansicht
Prev Vorheriger Beitrag   Nächster Beitrag Next
Ungelesen 09.12.09, 13:43   #5
flotti
Mitglied
 
Registriert seit: Mar 2009
Beiträge: 306
Bedankt: 21
flotti ist noch neu hier! | 0 Respekt Punkte
Standard

hier mal der klassiker in C:

Code:
#include <stdio.h>
#include <stdlib.h>

void swap(int *, int *);
void sort(int *, int);

int main (){
	
	int values []={10,58,4,1,4,7,1,47,4,1,452,4,8,2,6,8,7,4};
	int n = sizeof(values)/sizeof(*values);
	sort(&values[0],n);
	for(int i=0; i<n; i++)
		printf("%i \n",values[i]);
	system("pause");
	return 1337;

}

void sort(int *sortme, int n){
	for (int i=n-1; i>=0; i--){
		for(int j=0; j<i; j++)
		{
			if(sortme[j]>sortme[j+1])
				swap(&sortme[j],&sortme[j+1]);
		}
	}

}


void swap(int *x, int *y)
{
	int temp;
	temp = *x;
	*x = *y;
	*y = temp;
}
flotti ist offline   Mit Zitat antworten
 


Forumregeln
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren

BB code is An
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:04 Uhr.


Sitemap

().