Fork me on GitHub

查看系统配置的c++代码(评测机配置和获取G++版本编辑器版本)

获取G++版本编辑器版本

#include <iostream>
#include <sstream>

using namespace std;

std::string ver_string(int a, int b, int c) {
  std::ostringstream ss;
  ss << a << '.' << b << '.' << c;
  return ss.str();
}
int main() {
      std::string true_cxx =
#ifdef __clang__
   "clang++";
#else
   "g++";
#endif

  std::string true_cxx_ver =
#ifdef __clang__
    ver_string(__clang_major__, __clang_minor__, __clang_patchlevel__);
#else
    ver_string(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#endif

    cout << true_cxx_ver << endl;
    
    return 0;
}

查看评测姬配置

#include <stdint.h>
#include <iostream>
#include <cpuid.h>
using namespace std;
static void cpuid(uint32_t func, uint32_t sub, uint32_t data[4]) {
    __cpuid_count(func, sub, data[0], data[1], data[2], data[3]);
}
int main() {
    uint32_t data[4];
    char str[48];
    for(int i = 0; i < 3; ++i) {
        cpuid(0x80000002 + i, 0, data);
        for(int j = 0; j < 4; ++j)
            reinterpret_cast<uint32_t*>(str)[i * 4 + j] = data[j];
    }
    cout << str;
}
posted @ 2020-03-31 11:22  熠丶  阅读(529)  评论(0编辑  收藏  举报