Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Write a function to convert any decimal positive integer into binary number.
Write a function to convert any decimal positive integer into binary number.
//The answer that best fits the meaning of the question does not exceed the knowledge points in this chapter. You can completely upgrade the following answers, which are concise and clear.

# include & ltstdio.h & gt

int tow(int *,int);

int tow(int a[],int n)

{ int Yu = 0;

And (n! =0)

{ a[Yu]= n % 2;

n = n/2;

yu++;

}

Return to;

}

int main()

{ int a[ 10000],num,n;

Printf ("input number:");

scanf("%d ",& ampnum);

n=tow(a,num);

for(n-; n & gt=0; N-)// Note the first n-here; Only once, without him, the array subscript will be out of bounds.

printf("%d ",a[n]);

Returns 0;

}