import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return string字符串一维数组 */ public String[] specialNumber (int n) { String[] result = new String[n]; for (int i = 1; i <= n ; i++) { if (i % 3 == 0 && i % 5 == 0) { result[i - 1] = "Nowcoder"; } else if (i % 3 == 0) { result[i - 1] = "Now"; } else if (i % 5 == 0) { result[i - 1] = "coder"; } else { result[i - 1] = i + ""; } } return result; } }
本题知识点分析:
1.字符串模拟
2.数学模拟
3.数学遍历
本题解题思路分析:
1.遍历从1到N
2.按照规则进行输入
3.最后返回字符串数组即可,这题稍微注意越界问题,其他没什么难的,数学模拟
本题使用编程语言: Java
如果这篇文章对您有帮助的话,可以点个赞支持一下,感谢~