当前位置:网站首页>HJ4 字符串分隔
HJ4 字符串分隔
2022-08-07 14:00:00 【哈希嘻哈】
描述
输入描述:
•输入一个字符串,请按长度为8拆分每个输入字符串并进行输出;
•长度不是8整数倍的字符串请在后面补数字0,空字符串不处理。
输入描述:
连续输入字符串(每个字符串长度小于等于100)
输出描述:
依次输出所有分割后的长度为8的新字符串
示例1
输入:
abc
输出:
abc00000
代码
var str = readline()
for(let i = 0 ; i < str.length; i++) {
if (i % 8 === 0) {
var arr = str.substr(i , 8) // 从start开始,返回length长度字符,开始的位置从0不是1,支持负数,不支持数组
console.log(arr.padEnd(8 , 0)) // padEnd()用于尾部补全
}
}
边栏推荐
猜你喜欢

FairMOT Online Tracking Framework and Code Learning Records

室内定位之CSI指纹定位

如何判断一个点在多边形内

Network Foundation (3) 02-Basic Concept of Network - DNS server hosts file configuration & three-way handshake of website access process & BS architecture - browser access, CS architecture - installat

实现Sprite的Circle Fill效果及打了图集出现的问题

网安学习-应急响应1

Red team web management information collection

DiskGenius Installation Tutorial

ENScanGo主域名批量提取脚本

数据治理(二):数据治理功能方面
随机推荐
B-end product design process--product positioning
07.自定义指令传参小窍门
传统网站与数字化网站的对比
Qt实现基于matchtemplate的长截图
Navicat gets stuck for a few seconds after connecting to mysql for a period of time
6. Chinese version of cuBLAS Development Guide--SetStream() and SetWorkspace() in cuBLAS
eyb:创建过程:搭建环境到显示菜单(一)
【MySql进阶】索引详解(二):Mysql InnoDB索引原理、B+树、聚簇索引、二级索引、联合索引
数据治理(二):数据治理功能方面
Lombok常用方法及原理介绍
内存管理(三)——内存分页
keil编程问题 -- main.c(75): warning: #223-D: function “XXX“ declared implicitly
Postgresql logical backup tools pg_dump and pg_resotre learning
Image effect display (below)
6.cuBLAS开发指南中文版--cuBLAS中的SetStream()和SetWorkspace()
MySQL数据表中带OR的多条件查询
excel sumifs多条件求和
Measure the size of objects in an image using OpenCV
关于LANC控制镜头中出现的问题
Red team web management information collection