Пример #1
0
int main()
{
	int ar[MAX] = { 14, 18, 92, 13, 12, 6, 18, 37, 4, 10 };
	print_ar(ar, MAX);
	qsort(ar, 0, MAX);
	print_ar(ar, MAX);
}
Пример #2
0
int main()
{
	int ar[MAX] = { 45, 12, 19, 87, 72, 13, 10, 9, 21, 74 };

	print_ar(ar, MAX);
	for (int i = parent(MAX); i >= 0; i--)
		heapify(ar, MAX, i);
	print_ar(ar, MAX);
	return 0;
}
void f(int ai[], int n) {
    const int las = 10;
    int la[las];
    for (int i = 0; i<las; ++i) la[i] = ga[i];
    print_ar(la,las);
    cout << "\n";
    int* p = new int[n];
    for (int i = 0; i<n; ++i) p[i] = ai[i];
    print_ar(p,n);
    cout << "\n";
    delete[] p;
}
Пример #4
0
void insertionSort(int ar_size, int *  ar) {
    int value =  ar[ar_size-1],i;

    for(i = 2; i <= ar_size; i++) {
        if(ar[ar_size-i] > value ) {
            ar[ar_size-i+1] = ar[ar_size-i];
            print_ar(ar_size, ar);
        }else {
            ar[ar_size-i+1] = value;
            print_ar(ar_size, ar);
            break;
        }
        if(i == ar_size && ar[0] > value) {
            ar[0] = value;
            print_ar(ar_size, ar);
        }
    }
}
Пример #5
0
int main( int argc, char** argv )
{
	int i = 0;
	int j = 0;
	int ar[CSZ][RSZ] = { { 0 } };

	srand(time(NULL));

	for( i = 0; i < CSZ; i++ )
		for( j = 0; j < RSZ; j++ )
			ar[i][j] = rand() % MAX;
	
	printf( "input array:\n" );
	print_ar( ar, CSZ, RSZ );
	printf( "\n" );
	rotate_90r( ar, CSZ, RSZ );
	rotate_90l( ar, CSZ, RSZ );
	printf( "rotated array:\n" );
	print_ar( ar, CSZ, RSZ );
	printf( "\n" );

	return 0;
}