zoukankan      html  css  js  c++  java
  • hdu 2207水题

    这题是大水题。不过我用了一种比较诡异的写法,也不是为了装逼,主要是为了熟悉一下bitset的用法以及数据类型的转换。

    /*
     * hdu2207/win.cpp
     * Created on: 2012-11-5
     * Author    : ben
     */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    #include <bitset>
    using namespace std;
    
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("data.in", "r", stdin);
    #endif
        int n;
        while(scanf("%d", &n) == 1) {
            n += 2;
            string temp("11111111111111111111111111111111");
            for(int i = 31; i > 0; i--) {
                if(n > 0) {
                    temp[i] = '0';
                }
                n >>= 1;
            }
            bitset<32> b(temp);
            unsigned char *p = (unsigned char *)(&b);
            for(int i = 3; i > 0; i--) {
                printf("%u.", (unsigned int)p[i]);
            }
            printf("%u\n", (unsigned int)p[0]);
        }
        return 0;
    }
  • 相关阅读:
    poj2138 Travel Games
    [TJOI2013]松鼠聚会
    [HNOI2013]切糕
    CSS应用
    列表数据显示+分页
    SESSION的应用
    JS中正规表达式的用法以及常用的方法总结
    CSS 定位 (Positioning)
    CSS 边距
    选项卡应用
  • 原文地址:https://www.cnblogs.com/moonbay/p/2755049.html
Copyright © 2011-2022 走看看