codice:
#include <stdio.h>

void sort(int [], int);
void printv(int [], int);

int main(int argc)
{
	int v[] = {4, 9, 2, 3, 6, 1};
	printv(v, 5);
	puts(" == ");
	sort(v, 5);
	puts(" == ");
	printv(v, 5);
	return 0;
} 

void sort(int v[], int size)
{
	int i, tmp;
	for(i = 0; i < size; i++)
	{
		if(v[i] < v[i+1])
		{
			printf("%d => %d\n", v[i], v[i+1]);
			tmp = v[i+1];
			v[i+1] = v[i];
			v[i] = tmp;
		}
		if(v[i] > v[i-1])
		{
			printf("%d => %d\n", v[i], v[i+1]);
			tmp = v[i-1];
			v[i-1] = v[i];
			v[i] = tmp;
		}
	}
}

void printv(int v[], int size)
{
	int i;
	for(i = 0; i < size; i++)
	{
		printf("%d\n", v[i]);
	}

}
Mi da come out:

codice:
  
ouroboros@ouroboros-desktop:~/Desktop$ gcc -O2 -s -o Out sort.c
ouroboros@ouroboros-desktop:~/Desktop$ ./Out
4
9
2
3
6
 ==
4 => 9
2 => 3
2 => 6
6 => 2
 ==
9
4
6
3
2
Cosa sbaglio(è da un po che non tocco C...)???

Tnks