现在有一个数,请分别判断它是否可能是二进制、八进制、十进制、十六进制。例如 6AFF 只可能是十六进制,而 1011 则四种进制皆有可能。输入 N(1 ≤ N ≤ 1000)个字符串(长度不超过 10),每行输出 4 个数(空格分隔),分别表示能否表示二、八、十、十六进制数,1 表示可能、0 表示不可能。下面程序横线处可满足要求的是( )。
#include <iostream>
using namespace std;
int main() {
int n = 0;
cin >> n;
for (int i = 0; i < n; i++) {
char str[11];
cin >> str;
char max = '0';
for (int i = 0; str[i] != '\0'; i++)
if (str[i] > max)
max = str[i];
___________________________ // L1
}
return 0;
}
- A. cout << (max >= '1') << " " << (max >= '7') << " " << (max >= '9') << " " << (max >= 'F') << endl;
- B. cout << (max <= '1') << " " << (max <= '7') << " " << (max <= '9') << " " << (max <= 'F') << endl;
- C. cout << (max = '1') << " " << (max = '7') << " " << (max = '9') << " " << (max = 'F') << endl;
- D. cout << (max < '1') << " " << (max < '7') << " " << (max < '9') << " " << (max < 'F') << endl;
正确答案:B