1. judge whether a number is a return number.
# Include
Int main (void)
{
Int a [100] = {0 };
Int n;
Printf ("input n :");
Scanf ("% d", & n );
Int I, k, j;
K = 0;
J = 0;
While (n! = 0)
{
A [k ++] = n % 10;
N = n/10;
J ++;
}
For (I = 0; I <j; I ++)
If (a [I] = a [j-i-1])
Printf ("OK ");
Else
Printf ("no ");
Return 0;
}
If all outputs are OK, the return number is used. If there is no, the return number is not used.
This code converts the number into an array and determines whether it is the number of input files based on the array advantages. Although the efficiency is not high, this idea is quite good.
Sort by pointer:
# Include
Int main (void)
{
Int I, data [8], * p1, * p2, temp;
P1 = data;
Printf ("input data :");
For (I = 0; I <8; I ++)
{
Scanf ("% d", p1 );
P1 ++;
}
For (p1 = data; p1 <data + 8-1; p1 ++)
For (p2 = p1 + 1; p2 <data + 8; p2 ++)
If (* p1 <* p2)
{
Temp = * p1;
* P1 = * p2;
* P2 = temp;
}
For (I = 0, p1 = data; I <8; I ++, p1 ++)
Printf ("% 6d", * p1 );
Return 0;
}
Pointers have always been the biggest headache and the best part of the C language. Pointers are basically unique to the C language. This is a simple program. You only need to understand the following points:
1. int a, * p;
* P =;
P = &;
Int * p is an int * data type, * p is a pointer to the int type, and p is an address, but its foundation is that * p must only have one address.
2. The array is actually a pointer. data = data [0] indicates the first address of the array.
So p = data;
3. If a is a constant, * (p + a) = data [a].