X语言
主页
规范
Book
安装
快速开始
Playground
X语言在线Playground
X语言代码编辑器
选择示例
Hello World
算术运算
条件语句
循环
函数定义
数据结构
错误处理
运行
重置
代码
// X 语言 Playground 默认示例 // 变量声明 let x = 5 let y = 10 println("x = " + x) println("y = " + y) // 算术运算 let sum = x + y let difference = x - y let product = x * y let quotient = y / x println("sum = " + sum) println("difference = " + difference) println("product = " + product) println("quotient = " + quotient) // 条件语句 if x > y { println("x is greater than y") } else if x < y { println("x is less than y") } else { println("x is equal to y") } // 循环 println("Counting from 1 to 5:") let mutable i = 1 while i <= 5 { println(i) i = i + 1 }
输出
点击"运行"按钮执行代码...