UVA_446_Kibbles "n" Bits "n" Bits "n" Bits
来源:互联网 发布:右友是一款什么软件 编辑:程序博客网 时间:2024/06/04 18:08
#include<iostream> #include<sstream> #include<string> #include<vector> #include<list> #include<set> #include<map> #include<stack> #include<queue> #include<algorithm> #include<bitset>#pragma warning(disable:4996) using std::cin;using std::cout;using std::endl;using std::stringstream;using std::string;using std::vector;using std::list;using std::pair;using std::set;using std::multiset;using std::map;using std::multimap;using std::stack;using std::queue;using std::priority_queue;using std::bitset;int HexToDecimal(const string &hex){int ret = 0;for (size_t i = 0; i < hex.size(); i++){ret *= 16;switch (hex[i]){case '0':ret += 0; break;case '1':ret += 1; break;case '2':ret += 2; break;case '3':ret += 3; break;case '4':ret += 4; break;case '5':ret += 5; break;case '6':ret += 6; break;case '7':ret += 7; break;case '8':ret += 8; break;case '9':ret += 9; break;case 'A':ret += 10; break;case 'B':ret += 11; break;case 'C':ret += 12; break;case 'D':ret += 13; break;case 'E':ret += 14; break;case 'F':ret += 15; break;default:break;}}return ret;}int main(){//freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);int T;while (cin >> T){cin.get();while (T--){string hex1, Operator, hex2;cin >> hex1 >> Operator >> hex2;auto decimal1 = HexToDecimal(hex1);auto decimal2 = HexToDecimal(hex2);cout << bitset<13>(decimal1) << ' '<< Operator<<' ' << bitset<13>(decimal2) << " = ";if (Operator == "+"){cout << decimal1 + decimal2 << endl;}else{cout << decimal1 - decimal2 << endl;}}}return 0;}
0 0
- UVA_446_Kibbles "n" Bits "n" Bits "n" Bits
- UVa 446 - Kibbles "n" Bits "n" Bits "n" Bits
- Number of 1 Bits n&(n-1)的妙用
- Bits
- Bits*
- #leetcode#191 Number of 1 Bits n&n-1的用处
- 编写函数实现:clear all but least signficant n bits of x
- Count total set bits in all numbers from 1 to n
- set all bits between i and j in N equal to M
- [CrackCode] 5.1 Set all bits between i and j in N equal to M
- LeetCode:Counting Bits(高效计算n内所有数的置位数)
- Persistent Bits
- Changing Bits
- leetcode_num190_Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- Reverse Bits
- vb作业
- 多线程编程API简介 中
- Ffmpeg安装 ubuntu
- mysql变量使用总结
- SQL-SELECT-检索数据(二)
- UVA_446_Kibbles "n" Bits "n" Bits "n" Bits
- c句柄
- 笔记:构建嵌入式Linux系统(第二版)—— 第一章 概述
- C++11 多线程gcc编译简单示例
- 实用的web开发技术参考网址
- Angularjs练手篇——Server编写
- Linux 更改目录及子目录权限
- jenkins slave搭建
- @PathVariable