大厂笔试题
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.7 KiB

  1. /*
  2. :32reg1reg2reg3 alarm
  3. reg1的第八位为状态位1reg2的0~3reg3 24~31
  4. :0.1[-204, 204],
  5. tuefalse1ture
  6. :reg1reg2reg3 (3216)alam(32 10
  7. ):
  8. :88 18000A1F 12345678 120
  9. :0x0x12181.8:tue报警阈值 120 tue.
  10. :88 12000a1a df12fe2d 120;0xa0xd74.3:false报警國值 120false
  11. */
  12. #include <bits/stdc++.h>
  13. using namespace std;
  14. int main() {
  15. unsigned int reg1,reg2,reg3;
  16. cin >> hex >> reg1 >> hex >> reg2 >> hex >> reg3;
  17. int alarm;
  18. cin >> dec >> alarm;
  19. if(reg1 & 0x100){
  20. cout << "true" << endl;
  21. cout << "111" << endl;
  22. }
  23. else{
  24. reg2 &= 0x0f;
  25. reg3 &= 0xff000000;
  26. reg3 = reg3 >> 24;
  27. reg2 = reg2 << 8;
  28. unsigned int tmp = (reg2 + reg3);
  29. unsigned int tmp2 = tmp - 0x7f8;
  30. if(tmp2 > alarm*10)cout << "true" << endl;
  31. else cout << "false" << endl;;
  32. }
  33. return 0;
  34. }