下述代码在鲲鹏平台上运行,最终的运行结果是?
#include
#define judge_negative_or_not(x) \
((x) < 0 ? printf("negative") : \
((x) == 0) ? printf("zero") : \
printf("positive"))
int main()
{
unsigned char ch1 = -1;
char ch2 = -1;
signed char ch3 = -1;
printf("unsigned char ch1 = 0x%x, %d, ", ch1, ch1),
judge_negative_or_not(ch1), printf("\n");
printf(" char ch2 = 0x%x, %d, ", ch2, ch2),
judge_negative_or_not(ch2), printf("\n");
printf(" signed char ch3 = 0x%x, %d, ", ch3, ch3),
judge_negative_or_not(ch3), printf("\n");
return 0;
}
A
unsigned char ch1 = 0xff, 255, positive
char ch2 = 0xffffffff, -1, negative
signed char ch3 = 0xffffffff, -1, negative
B
unsigned char ch1 = 0xff, 255, positive
char ch2 = 0xffffffff, 255, negative
signed char ch3 = 0xffffffff, -1, negative
C
unsigned char ch1 = 0xff, 255, positive
char ch2 = 0xff, 255, positive
signed char ch3 = 0xffffffff, -1, negative
D
unsigned char ch1 = 0xff, 255, positive
char ch2 = 0xff, -1, positive
signed char ch3 = 0xffffffff, -1, negative
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main() {
int l, r, mid,n;
l = 0;
char str[10] = { 0,1,2,3,4,5,6,7,8,9 };
printf("请输入你要查找的值\n");
scanf("%d", &n);
r= sizeof(str) / (sizeof(str[0]))-1;
mid = (r + l) / 2;
while (l <= r) {
if (n > str[mid]) {
l = mid + 1;
}
if (n < str[mid]) {
r = mid - 1;
}
if(n==str[mid]) {
printf("%d\n", mid);
break;
}
mid = (r + l) / 2;
}
if (l > r)return -1;
system("pause");
return 0;
}
unsigned char ch1 = 0xff, 255, positive
char ch2 = 0xffffffff, -1, negative
signed char ch3 = 0xffffffff, -1, negative