1. Mutual full count
# Include
# Include
Int fun (int n );
Int main (void)
{
Int x, y;
For (x = 1; x <3000; x ++)
{
For (y = 1; y <x; y ++)
{
If (fun (x) = y & fun (y) = x)
Printf ("% d \ t", x, y );
}
}
Return 0;
}
Int fun (int n)
{
Int I, sum = 0;
For (I = 1; I <= sqrt (n); I ++)
{
If (n % I = 0)
Sum = sum + I;
}
Return sum;
}
2. Quick sorting
# Include
# Include
# Include
# Define N 1000
Void quick_sort (int a [N + 1], int left, int right)
{
Int I, j, temp;
If (left <right)
{
Temp = a [left];
I = left;
J = right;
While (I! = J)
{
While (a [j] <= temp & j> I)
J --;
If (j> I)
A [I ++] = a [j];
While (a [I]> temp & j> I)
I ++;
If (j> I)
A [j --] = a [I];
}
A [I] = temp;
Quick_sort (a, left, I-1 );
Quick_sort (a, I + 1, right );
}
}
Int main (void)
{
Int I;
Int a [N + 1];
Srand (time (NULL ));
For (I = 1; I <= N; I ++)
A [I] = rand () % N + 1;
Printf ("\ n output in the original order: \ n ");
For (I = 1; I <= N; I ++)
Printf ("% 8d", a [I]);
System ("pause ");
Quick_sort (a, 1, N );
Printf ("\ n output in New Order: \ n ");
For (I = 1; I <= N; I ++)
Printf ("% 8d", a [I]);
Printf ("\ n ");
Return 0;
}