以下是微小位元的測試,實際是就是二進位運算啦,考是算錯(怪怪)
#include<stdio.h> int main(void){ int a = 44; int b = 55; int c = 33; int d = -20; printf("uni-micro operator: \n"); printf("a & b = %d\n", a & b); printf("b & c = %d\n", b & c); printf("c & d = %d\n", c & d); printf("b & b = %d\n", b & b); printf("a | b = %d\n", a | b); printf("double-micro operator: \n"); printf("a && b = %d\n", a && b); printf("a || b = %d\n", a || b); printf("while-micro operator: \n"); while( a & b){ printf("a ^ b = %d, ", a ^ b); a--; if(a < 40){ break; } } printf("\n"); while( a ^ d){ printf("a ^ d = %d, ", a ^ d); a--; if( a ^ d < 0){ break; } } return 0; }結果:
uni-micro operator: a & b = 36 b & c = 33 c & d = 32 b & b = 55 a | b = 63 double-micro operator: a && b = 1 a || b = 1 while-micro operator: a ^ b = 27, a ^ b = 28, a ^ b = 29, a ^ b = 30, a ^ b = 31, a ^ d = -53,
由結果知道,while迴圈對負號的數值也會進入迴圈跑,我之前已為負的就不會跑= ="
學習中...
0 意見:
張貼留言