sicily 1625

来源:互联网 发布:utorrent做种中 知乎 编辑:程序博客网 时间:2024/04/30 22:03
#include "iostream"#include "bitset"#include "string"#include "sstream"using namespace std;int main(){int TestCase;cin >> TestCase;int Case = 0;while (TestCase--){Case++;string str;//对输入的字符串的存储cin >> str;int size = str.size();string temp = "";int a[3], count = 0;for (int i = 0; i < size; i++)//将字符串转换为数字{if (str[i] != ':')temp += str[i];if (str[i] == ':' ){stringstream s;s << temp;s >> a[count];count++;temp = "";}if (i == 7){stringstream s;s << temp;s >> a[count];count++;temp = "";}}int H = a[0], M = a[1], S = a[2];bitset<6> bH;bitset<6> bM;bitset<6> bS;//对bitset容器中的位进行设置for (int i = 5; i >= 0; i--){int remainder;remainder = H % 2;H /= 2;if (remainder == 1)bH.set(i, 1);}for (int i = 5; i >= 0; i--){int remainder;remainder = M % 2;M /= 2;if (remainder == 1)bM.set(i, 1);}for (int i = 5; i >= 0; i--){int remainder;remainder = S % 2;S /= 2;if (remainder == 1)bS.set(i, 1);}//输出cout << Case << " ";for (int i = 0; i < 6; i++)cout << bH[i] << bM[i] << bS[i];cout << " ";for (int i = 0; i < 6; i++)cout << bH[i];for (int i = 0; i < 6; i++)cout << bM[i];for (int i = 0; i < 6; i++)cout << bS[i];cout << endl;}}

 
原创粉丝点击