参考:
【Java版本】常用代码模板1——基础算法 + 模板题参考实现 - AcWing
【Java版本】常用代码模板2——数据结构 + 模板题参考实现 - AcWing

题目一:
输入:abc def ghi
输出:abc
def
ghi
题解:
public class Main {
public static void main(String[] args) {
String s = "abc def ghi";
char[] str = s.toCharArray();
int n = str.length;
for (int i = 0; i < n; i++) {
int j = i;
while (j < n && str[j] != ' ') j++;
for (int k = i; k < j; k++) {
System.out.print(str[k]);
}
System.out.println();
i = j;
}
}
}

4650

被折叠的 条评论
为什么被折叠?



