标签:color public array 分享 src tar div 来源 param
------------------------
AC代码:
class Solution { /** * param n: As description. * return: A list of strings. */ public ArrayList<String> fizzBuzz(int n) { ArrayList<String> results = new ArrayList<String>(); for (int i = 1; i <= n; i++) { if (i % 15 == 0) { results.add("fizz buzz"); } else if (i % 5 == 0) { results.add("buzz"); } else if (i % 3 == 0) { results.add("fizz"); } else { results.add(String.valueOf(i)); } } return results; } }
题目来源: http://www.lintcode.com/zh-cn/problem/fizz-buzz/
标签:color public array 分享 src tar div 来源 param
原文地址:http://www.cnblogs.com/cc11001100/p/6241547.html