Insert 'value' into every element but the first

/* The following code example is taken from the book
 * "The C++ Standard Library - A Tutorial and Reference"
 * by Nicolai M. Josuttis, Addison-Wesley, 1999
 *
 * (C) Copyright Nicolai M. Josuttis 1999.
 * Permission to copy, use, modify, sell and distribute this software
 * is granted provided this copyright notice appears in all copies.
 * This software is provided "as is" without express or implied
 * warranty, and with no claim as to its suitability for any purpose.
 */
#include <iostream>
#include <deque>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;

int main()
{
    // create empty deque of strings
    deque<string> coll;

    // insert several elements
    coll.assign (3, string("string"));
    coll.push_back ("last string");
    coll.push_front ("BBB string");
    coll.push_front ("CCC string");
    coll.push_front ("AAA string");

    // print elements separated by newlines
    copy (coll.begin(), coll.end(),ostream_iterator<string>(cout,"\n"));
    cout << endl;

    // insert ''another'' into every element but the first
    for (unsigned i=1; i<coll.size(); ++i) {
        coll[i] = "another " + coll[i];
    }

    // print elements separated by newlines
    copy (coll.begin(), coll.end(),ostream_iterator<string>(cout,"\n"));
    cout << endl;

}

/* 
AAA string
CCC string
BBB string
string
string
string
last string

AAA string
another CCC string
another BBB string
another string
another string
another string
another last string


 */    

引用:隐示方法插入默认值的示例是在插入数据时,可以通过声明插入表时忽略某些字段,使其自动生成默认值。比如在插入学生表时,可以只插入姓名和年龄,而忽略性别字段,使其自动生成默认值。 引用:插入多条数据的示例是可以一次性插入多条记录到表中。比如通过使用insert into 表名 values(1, 'god'), (2, 'godd'), (3, 'goddd'),可以一次性插入三条记录到表中。 引用:使用insert into table(field, …)values(value, …)可以在插入数据时指定字段和对应的值,可以一次性插入多条记录。另外,还可以使用insert into table(field, …)select(value,…) union all select(value,…) union all ...的方式,通过select语句查询出的结果插入到表中。 因此,insert into value是用于在插入数据时指定字段和对应的值,可以一次性插入多条记录的操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [SQL基础_数据插入(INSERT INTO...VALUES...)](https://blog.csdn.net/weixin_45280346/article/details/95725971)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [数据库基础点](https://blog.csdn.net/qq_41506131/article/details/112276231)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [mssql insert into 和insert into select性能比较](https://download.csdn.net/download/weixin_38657457/13694986)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值