强训第37天

选择

B

D

D

网络号最高才247开头

主机号全为0是网络号

D

28位网络号 则第四个字节是1111 0000(240) 按位与91得80(0101 0000)

最大就是后面四个主机号全为1即80+15=95而且是广播IP

或者全部拿来比一下网络号

B

首先发数据肯定从低到高发。网络中要转成大端字节序。

在x86平台上为小端存储在内存上由低到高位12 34 56 78,转为大端变成 78 56 34 12

所以顺序是78 56 34 12

A

主机号占九位 2^9=512 减网络号 广播 和网关设备 =509

D

子网掩码要是连续的

D

DNS用的UDP

A

D

需要六个子网 所以需要至少3位充当网络号 所以剩了5个比特位充当主机号(2^5>26)符合

所以第四个字节的前三个字节是1 1110 0000为224

编程

数据库连接池

数据库连接池__牛客网

cpp 复制代码
#include <iostream>
#include <string.h>
#include <vector>
#include <string>
using namespace std;

int main() 
{
    int n;
    while(cin>>n)
    {
        string num,op;
        int res=0;
        int have=0;
        for(int i=0;i<n;i++)
        {
            cin>>num>>op;
            if(op=="connect")
            {
                if(have==0) res++;
                else have--;
            }
            else
            {
                have++;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}

mkdir

mkdir__牛客网

cpp 复制代码
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() 
{
    int n;
    while(cin>>n)
    {
        vector<string>strs(n);
        vector<bool>exist(n,true);
        for(int i=0;i<n;i++) 
        {
            // getline(cin,strs[i]);
            // getline会把空格也识别上来 慎用
            cin>>strs[i];
        }
        sort(strs.begin(),strs.end());
        for(int i=0;i<n-1;i++)
        {
            if(strs[i]==strs[i+1])
            {
                exist[i]=false;
            }
            else if(strs[i]==strs[i+1].substr(0,strs[i].size()) && strs[i+1][strs[i].size()] == '/')
            {
                exist[i]=false;
            }
        }
        string tmp="mkdir -p ";
        for(int i=0;i<strs.size();i++)
        {
            if(exist[i])
            {
                cout<<tmp<<strs[i]<<endl;
            }
        }
        cout<<endl;
    }
    return 0;
}
相关推荐
blasit2 天前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
肆忆_3 天前
# 用 5 个问题学懂 C++ 虚函数(入门级)
c++
不想写代码的星星3 天前
虚函数表:C++ 多态背后的那个男人
c++
端平入洛5 天前
delete又未完全delete
c++
端平入洛6 天前
auto有时不auto
c++
哇哈哈20217 天前
信号量和信号
linux·c++
多恩Stone7 天前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
蜡笔小马7 天前
21.Boost.Geometry disjoint、distance、envelope、equals、expand和for_each算法接口详解
c++·算法·boost
超级大福宝7 天前
N皇后问题:经典回溯算法的一些分析
数据结构·c++·算法·leetcode
weiabc7 天前
printf(“%lf“, ys) 和 cout << ys 输出的浮点数格式存在细微差异
数据结构·c++·算法