The first type:
#include <stdio.h>
int main ()
{
int zheng,i;
int m=0;
int yu[10];
int count=0;
scanf ("%d", &m);
Zheng=m;
for (i=0;i<10;i++)
if (zheng!=0)
{
yu[i]=zheng%10;
ZHENG=ZHENG/10;
count++;
}
for (i=0;i<count;i++)
{
printf ("%d", yu[i]);
}
return 0;
}
The second type:
#include <stdio.h>
int main ()
{
int num = 0;
int i = 0;
int arr[10];
int left = 0;
int right = 0;
int j = 0;
scanf ("%d", &num);
while (NUM)
{
Arr[i] = num% 10;
num = NUM/10;
i++;
}
Reverse the elements inside the arr[4]
right = I-1;
while (left < right)
{
int tmp = Arr[left];
Arr[left] = Arr[right];
Arr[right] = tmp;
left++;
right--;
}
Output
for (j = 0; J < i; J + +)
{
printf ("%d", arr[j]);
}
printf ("\ n");
return 0;
}
The Third kind: using recursion
#include <stdio.h>
void print (int num)//recursion
{
if (Num >= 10)
Print (NUM/10);
printf ("%d", num% 10);
}
int main ()
{
int num = 10;
scanf ("%d", &num);
print (num);
return 0;
}
Recursion from error-prone recursive examples--link http://c.biancheng.net/cpp/html/487.html
If a statement inside a function invokes the function itself, the function is called "recursive". Recursion is a process defined by itself. It can also be referred to as "circular definition".
This article is from the "Sunflower in the Sun" blog, please be sure to keep this source http://10796797.blog.51cto.com/10786797/1706972
Use the C language program to output a number of each bit (multiple methods)