[C语言] 判断两个数字是否都为1

#include <stdio.h>

int main(){

	int a = 1 ,b = 1;


	if(1 == (a&b)){
		printf("都是1:true.\n");
	}else{
	
		printf("都是1:false.\n");
	}

	return 0;
}

执行
都是1:true.

#include <stdio.h>

int main(){

	int a = 0 ,b = 1;


	if(1 == (a&b)){
		printf("都是1:true.\n");
	}else{
	
		printf("都是1:false.\n");
	}

	return 0;
}

执行
都是1:false.

posted @ 2022-02-14 15:03  方罗良  阅读(184)  评论(0)    收藏  举报