小编Mir*_*nen的帖子

如何有效地找到最小的正int?

我正在阅读文本,我想找到第一个句子的结尾,此时是".","?"或"!"的第一个索引.在一个字符串中.所以这是我的Java代码:

int next = -1;
int nextQ = text.indexOf("? ");
int nextE = text.indexOf("! ");
int nextDot = text.indexOf(". ");
if (nextDot > 0) {
    next = nextDot;
    if (nextQ > 0){
        if (nextQ < next) {next = nextQ;}
        if (nextE > 0) {
            if (nextE < next) {next = nextE;}
        }
    } else if (nextE > 0){
        if (nextE < next) {next = nextE;}
    }
} else if (nextQ > 0){
    next = nextQ;
    if (nextE > 0 && …
Run Code Online (Sandbox Code Playgroud)

java algorithm optimization

3
推荐指数
2
解决办法
120
查看次数

标签 统计

algorithm ×1

java ×1

optimization ×1