C语言入门 请大侠们指点

来源:百度知道 编辑:UC知道 时间:2024/06/27 07:25:06
#include<stdio.h>
#include <stdlib.h>
int main( )

{
int i=0,j,a,num[20];

printf("please input the number:");

scanf("%d",&a );
while(a!=0)
{
num[i++]=a%2;
a=a/2 ;
}
printf("\nthe binary is:");
for(j=i-1;j>=0;j--)
{ printf("%d",num[j]); }

system("pause");
return 0;
}
请问大侠们 用这个如何自定义函数f去表示 因为我要提取转变后的2进制的结果和 11110000 做&运算 实在不会 请指点迷津

void f(int a)
{
num[i++]=a%2;
a=a/2 ;
}

#include<stdio.h>
#include <stdlib.h>
int main( )

{
int i=0,j,a,num[20];

printf("please input the number:");

scanf("%d",&a );
while(a!=0)
{
f(a);
}
printf("\nthe binary is:");
for(j=i-1;j>=0;j--)
{ printf("%d",num[j]); }

system("pause");
return 0;
}

#include "stdio.h"
int i=0,num[20];/*定义全局变量*/
void main()
{
void f();
int j,a;
printf("please input the number:");

scanf("%d",&a );
f(a);
printf("\nthe binary is:");
for(j=i-1;j>=0;j--)
{ printf("%d",num[j]); }

system("pause");

}
void f(int a)
{
while(a!=0)
{
num[