为什么没有 Vimscript 语言

P1001 A+B Problem

tmp_get_zip_diff @ 2024-09-26 14:42:38

rt。

let g:x = 1
let g:y = 0

func! CursorMove()
    let g:y = g:y+1
    if g:y >= len(getline(g:x))
        let g:x = g:x+1
        let g:y = 0
    endif
endfunc

func IsNum(ch)
    if a:ch == '0'
        return 0
    elseif a:ch == '1'
        return 1
    elseif a:ch == '2'
        return 2
    elseif a:ch == '3'
        return 3
    elseif a:ch == '4'
        return 4
    elseif a:ch == '5'
        return 5
    elseif a:ch == '6'
        return 6
    elseif a:ch == '7'
        return 7
    elseif a:ch == '8'
        return 8
    elseif a:ch == '9'
        return 9
    endif
    return -1
endfunc

func! InputNum()
    let f = 1
    let X = 0
    while IsNum(getline(g:x)[g:y]) == -1
        if getline(g:x)[g:y] == '-'
            let f = -1
        endif
        call CursorMove()
    endwhile
    while IsNum(getline(g:x)[g:y]) != -1
        let X = X*10+IsNum(getline(g:x)[g:y])
        call CursorMove()
    endwhile
    return f*X
endfunc

let a = 0
let b = 0

func Solution()
    let a = InputNum()
    let b = InputNum()
    exec "echo a+b"
endfunc

by Terrible @ 2024-09-26 14:52:48

该贴 疑似 具有对“无意义”和违规讨论的界定规则第 32 条所述的“求评价某个事物,但不给出背景资料或者自己的观点的。”相应特征。


by nr0728 @ 2024-09-26 14:53:30

vim 这么强???


by 2012bsz @ 2024-09-26 15:37:58

@tmp_get_zip_diff 太废了吧你

echo input("") + input("")

by tmp_get_zip_diff @ 2024-09-26 15:39:04

@2012bsz 你这个不能处理同一行空格隔开的情况,但这题是这样的(而且不能文件输入)


by 2012bsz @ 2024-09-26 15:42:18

那就

let g:s = split(input(""))
echo s[0] + s[1]

by Binah_OVO @ 2024-09-29 19:43:02

666这个入是桂


|