zoukankan      html  css  js  c++  java
  • 输出ip最后一个点之后的数字

    #include "stdafx.h"
    #include <iostream>
    #include <ctime>
    #include <cstring>
    #include <cmath>
    #include <iostream>  
    #include <string>  
    #include <WinSock.h>  
    #include <fstream>  
    //#pragma comment(lib,"ws2_32.lib")
    using namespace  std;
    //bool sort(char * num,int totalNum);

    void _tmain(int argc, _TCHAR* argv[])
    {

          string IP1="172.16.26.29";

          string IP2="172.16.26.169";

          string IP3="172.16.223.23";

          string ss0=IP1.substr(IP1.find_last_of('.')+1,3);

          string ss1=IP2.substr(IP2.find_last_of('.')+1,3);

          string ss2=IP3.substr(IP3.find_last_of('.')+1,3);

          string ss3=IP2.substr(IP2.find_last_of('.')+1);    //当不给定第二个参数的时候,默认输出到末尾

         cout<<ss0<<endl;

         cout<<ss1<<endl;

         cout<<ss2<<endl;

         cout<<ss3<<endl;

    }

    输出:29

            169

            23

            169

  • 相关阅读:
    poj 2155 B
    hdu 1556 A
    hdu 1556 A
    #366 A-C
    最长上升子序列
    Codeforces Div3 #501 A-E(2) F以后补
    字典的建立 查找
    字典序大小
    头文件模板
    01背包模板 及 优化
  • 原文地址:https://www.cnblogs.com/loda333/p/5050662.html
Copyright © 2011-2022 走看看