zoukankan      html  css  js  c++  java
  • 算法之美--3.1.1 字符串

           明天回家了,也许是懒吧,这本书就开始学习了一段时间,后面就没有动过,本来博客专栏需要不断更新的,结果几个月没有动静了,认真想想,这本书上的东西真需要好好静下心来看才有收获,打算回家看看;晚上回去总结一下。

    /*!
     * file 算法之美--字符串.cpp
     * date 2017/01/19 20:48
     *
     * author ranjiewen
     * Contact: user@company.com
     *
     * rief 
     *
     * TODO: long description
     *
     * 
    ote
    */
    
    #include <iostream>
    #include <iomanip>
    #include <string>
     
    using namespace std;
    int main(int argc, char** argv)
    {
        string str = "高德纳 美国 计算机科学家 计算机程序设计艺术";
        string str_temp = "";
        str_temp.assign(str);
    
        string result[4] = {"","","",""};
        int position = 0;
        for (int i = 0; i < 3; i++)
        {
            position = str_temp.find(" ");
            result[i] = str_temp.substr(0, position);
            str_temp = str_temp.substr(position + 1, str_temp.length() - position);
    
        }
        result[3] = str_temp;
        cout << "姓名:" << setw(8) << result[0] << endl;
        cout << "国籍:" << setw(6) << result[1] << endl;
        cout << "职业:" << setw(14) << result[2] << endl;
        cout << "代表作:" << setw(18) << result[3] << endl;
    
        str_temp.swap(result[0]);   //将str_temp与reuslt[0]交换
        for (int j = 1; j < 4;j++)
        {
            str_temp += " ";
            str_temp.append(result[j]);
        }
        int equal = str.compare(str_temp);
        if (equal==0)
        {
            cout << "successful matching!" << endl;
        }
        else
        {
            cout << "Unsuccessful matching" << endl;
        }
    
        return 0;
    }
  • 相关阅读:
    asp.net控件开发基础(17)
    AjaxControlToolkit更新
    asp.net控件开发基础(18)
    asp.net控件开发基础(15)
    新装了vista,不容易啊
    asp.net控件开发基础(19)
    Oracle创建用户及数据表
    RMAN快速入门指南
    Oracle数据库中sql基础
    PL/SQL循序渐进全面学习教程Oracle
  • 原文地址:https://www.cnblogs.com/ranjiewen/p/6308814.html
Copyright © 2011-2022 走看看