趣味编程:静夜思(Kotlin版)
2024-09-10 18:33:24
import java.util.*
fun verticalWriting(txt:String, offset:Int) =
txt.mapIndexed { i, c -> Pair(i, c) }
.groupByTo(TreeMap(), { it.first % offset }, { it.second.toString() })
.forEach { println(it.value.reversed().joinToString("|")) }
fun main(args: Array<String>) =
verticalWriting("床前明月光疑是地上霜举头望明月低头思故乡", 5)
/*
低|举|疑|床
头|头|是|前
思|望|地|明
故|明|上|月
乡|月|霜|光
*/
最新文章
- BZOJ 3158: 千钧一发
- javascript设计模式与开发实践
- C++学习笔记28:运行期型式信息
- php 使用 极光推送 类
- hdu3033 背包变形
- oracle之压缩表
- Struts2+hibernate3+Spring2的整合方法
- Mac系统Finder访问资源库文件夹
- C# 线程--第四线程实例
- [swustoj 679] Secret Code
- poj1980
- python之爬虫
- Django应用部署 - 上线指南
- tomcat8 性能优化
- 收藏:Non-direct与direct ByteBuffer区别
- Men and women can&#39;t be &#39;just friends
- python 进行机器学习
- 还没有写完准备弡上cpickle 还有字典
- elasticsearch之JAVA环境变量报错:could not find java; set JAVA_HOME or ensure java is in PATH
- 【JQuery】事件冒泡及使用jQuery阻止