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

首頁 > 學院 > 開發設計 > 正文

LintCode 407:Plus One

2019-11-11 07:54:13
字體:
來源:轉載
供稿:網友

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;    }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 海口市| 南丹县| 新津县| 江陵县| 龙泉市| 双峰县| 保山市| 西华县| 浪卡子县| 长丰县| 岳西县| 东明县| 西藏| 疏勒县| 大连市| 巴林左旗| 筠连县| 紫金县| 济宁市| 安福县| 榆中县| 平昌县| 桑日县| 顺昌县| 焦作市| 永顺县| 兴仁县| 河西区| 昆山市| 武夷山市| 利津县| 周口市| 崇礼县| 秀山| 平凉市| 武鸣县| 洛扎县| 黄陵县| 兴山县| 天柱县| 昌邑市|