static String highgarden(String[] hardhome) { int oldCastle = hardhome.length / 2; for (int i = 2; i <= 4; i += 2) { String[] widowsWatch = { hardhome[oldCastle - i], hardhome[oldCastle], hardhome[oldCastle + i] }; String brightwaterKeep = dorne((widowsWatch)); if (brightwaterKeep != null) return brightwaterKeep; } return null; } static String dorne(String[] evenfallHall) { for (int i = 0; i < 2; i++){ if (evenfallHall[i] == null) return null; if (!evenfallHall[i].equals(evenfallHall[i + 1])) return null; } return evenfallHall[0]; }分别添加JavaDoc
时间: 2023-06-25 09:03:09 浏览: 43
/**
* 执行高庭算法,接收一个字符串数组作为参数
* @param hardhome 字符串数组,表示要执行算法的数据
* @return 返回一个字符串结果,如果找到了符合条件的结果,则返回该结果,否则返回null
*/
static String highgarden(String[] hardhome) {
int oldCastle = hardhome.length / 2;
for (int i = 2; i <= 4; i += 2) {
String[] widowsWatch = {
hardhome[oldCastle - i], hardhome[oldCastle], hardhome[oldCastle + i]
};
String brightwaterKeep = dorne((widowsWatch));
if (brightwaterKeep != null) return brightwaterKeep;
}
return null;
}
/**
* 执行多恩算法,接收一个字符串数组作为参数
* @param evenfallHall 字符串数组,表示要执行算法的数据
* @return 返回一个字符串结果,如果找到了符合条件的结果,则返回该结果,否则返回null
*/
static String dorne(String[] evenfallHall) {
for (int i = 0; i < 2; i++){
if (evenfallHall[i] == null) return null;
if (!evenfallHall[i].equals(evenfallHall[i + 1])) return null;
}
return evenfallHall[0];
}
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)