国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

LintCode 407:Plus One

2019-11-11 06:37:05
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

Note:

The use of Vector:1.initializeint x[10]={9,8,7,6,5,4,3,2,1,0};vector test(x,x+10);

2.end();begin();vector.begin() points to the first item,while vector.end() doesn't point to the last item but after it.

3.vector.insert(pointer which indicates the location to insert,the item)

class Solution {public:    /**     * @param digits a number rePResented as an array of digits     * @return the result     */    vector<int> plusOne(vector<int>& digits) {        // Write your code here        vector<int>::iterator p1;        p1=digits.end()-1;        while(*p1==9){            *p1=0;            p1--;        }        if(p1!=digits.begin()-1)            (*p1)++;        else            digits.insert(digits.begin(),1);        return digits;    }};
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 溆浦县| 渭源县| 恩平市| 喜德县| 凌海市| 蒲江县| 宾阳县| 启东市| 丰镇市| 剑河县| 安丘市| 永昌县| 扶绥县| 莱州市| 府谷县| 右玉县| 明水县| 库车县| 奇台县| 富宁县| 甘孜县| 临安市| 德安县| 阿鲁科尔沁旗| 商城县| 梁山县| 壶关县| 射洪县| 台东市| 梨树县| 陆川县| 巴楚县| 专栏| 柏乡县| 呼和浩特市| 土默特左旗| 大城县| 信宜市| 错那县| 满洲里市| 会宁县|