37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""逐行写真实 stdout;对端均逐项格式化、持锁写入并传播系统错误。"""
|
|
|
|
|
|
def source(language):
|
|
if language == 'dever':
|
|
return '''loop measure(n: Int) (out: Int)
|
|
| each value in range(0, n) | result |
|
|
| out | do dever.io.println(int.toText(value)) |
|
|
cmd bench = measure
|
|
'''
|
|
if language == 'rust':
|
|
return '''use std::io::{self, Write};
|
|
fn line(text: &str) -> io::Result<()> { writeln!(io::stdout().lock(), "{text}") }
|
|
fn main() -> io::Result<()> {
|
|
let n: i64 = std::env::args().nth(1).unwrap().parse().unwrap();
|
|
let mut count = 0i64;
|
|
for value in 0..n {
|
|
line(&value.to_string())?;
|
|
count = count.checked_add(1).unwrap();
|
|
}
|
|
println!("{count}");
|
|
Ok(())
|
|
}
|
|
'''
|
|
return '''package main
|
|
import ("fmt"; "os"; "strconv")
|
|
func main() {
|
|
n, err := strconv.ParseInt(os.Args[1], 10, 64); if err != nil { panic(err) }
|
|
count := int64(0)
|
|
for value := int64(0); value < n; value++ {
|
|
if _, err := fmt.Fprintln(os.Stdout, strconv.FormatInt(value, 10)); err != nil { panic(err) }
|
|
count++
|
|
}
|
|
fmt.Println(count)
|
|
}
|
|
'''
|