左填充-LintCode
来源:互联网 发布:购买高权重网站域名 编辑:程序博客网 时间:2024/04/28 03:06
实现一个leftpad库,如果不知道什么是leftpad可以看样例
样例:
leftpad("foo", 5)>> " foo"leftpad("foobar", 6)>> "foobar"leftpad("1", 2, "0")>> "01"
#ifndef C524_H#define C524_H#include<iostream>#include<string>using namespace std;class StringUtils {public: /* * @param originalStr: the string we want to append to * @param size: the target length of the string * @param padChar: the character to pad to the left side of the string * @return: A string */ static string leftPad(string &originalStr, int size, char padChar = ' ') { // write your code here int num = size - originalStr.size(); while (num > 0) { originalStr = padChar + originalStr; num--; } return originalStr; }}; #endif
阅读全文
0 0
- LintCode - 524.左填充
- 【lintcode】leftpad 左填充
- 左填充-LintCode
- 左填充
- 左填充
- 左填充
- 左填充
- LintCode算法题解——移动零、玩具工厂、左填充、丑数
- Oracle 左填充 右填充
- java 左填充
- LintCode_524_左填充
- 左旋转二进制位-LintCode
- oracle左填充lpad右填充rpad
- 524.Left Pad-左填充(容易题)
- 数据结构实例<七>(Left-Pad 左填充)容易
- Java中数字转换为固定长度的字符串,并左填充为0
- PHP之生成左填充0的编号(存储到MYSQL)
- LintCode
- svn上传拉取
- 数据结构-循环队列的基本操作
- iOS11 & iPhone X 适配指南
- 自定义圆形进度条
- PC标签保留参数phpcms
- 左填充-LintCode
- (工作中)springmvc的对字典表的使用@dict
- 使用 STM32 测量频率和占空比的几种方法
- codeforces 776E
- UE4(六) AssetManager文件资产管理以及动画批量导入
- rsa 与加密机
- Lintcode156 Merge Intervals solution 题解
- 简单搭建一个maven项目
- 强大的图片加载框架Fresco的使用