1 Star 4 Fork 1

张磊/cangjie_practice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
read_demo.cj 653 Bytes
一键复制 编辑 原始数据 按行查看 历史
张磊 提交于 2025-07-13 16:27 +08:00 . 适配仓颉语言1.0.0正式版本
import std.console.*
main() {
println("The characters you entered will be returned as is. Enter q to exit:")
try {
//读取一个字符
var ch = Console.stdIn.read().getOrThrow()
//判断输入的是否是字符q,如果是就退出,否则继续循环
while (ch != 'q') {
//输入的字符是不是换行,如果不是就打印该字符
if (ch != '\n') {
println(ch)
}
//重新读取一个字符
ch = Console.stdIn.read().getOrThrow()
}
} catch (e: Exception) {
println("An error occurred:" + e.message)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zl3624/cangjie_practice.git
git@gitee.com:zl3624/cangjie_practice.git
zl3624
cangjie_practice
cangjie_practice
master

搜索帮助