跳到正文

个人记录

m

EXCEED88约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年8月17日
收录
2026年8月17日
更新
2026年8月17日
篇幅
约 2 分钟

版本

  1. v1当前

#include <iostream> #include <string> using namespace std;

bool isBin(string s) { for (char c : s) { if (c != ‘0’ && c != ‘1’) return false; } return true; }

bool isOct(string s) { for (char c : s) { if (c < ‘0’ || c > ‘7’) return false; } return true; }

bool isDec(string s) { for (char c : s) { if (c < ‘0’ || c > ‘9’) return false; } return true; }

bool isHex(string s) { for (char c : s) { if (!((c >= ‘0’ && c <= ‘9’) || (c >= ‘A’ && c <= ‘F’))) { return false; } } return true; }

int main() { int n; cin >> n; while (n—) { string s; cin >> s;

代码
    cout << isBin(s) << " "
         << isOct(s) << " "
         << isDec(s) << " "
         << isHex(s) << endl;
}
return 0;
原文