2 回答
TA贡献1810条经验 获得超5个赞
k = int(input()) # useless given what we're doing below
cases = [int(i) for i in input().split()]
for case in cases:
for k in range(1, case + 1):
out = ""
if (k % 3) == 0:
out += "fizz"
if (k % 5) == 0:
out += "buzz"
if out != "":
print(out)
else:
print(k)
第二行是简写
cases = []
for i in input().split():
cases.append(int(i))
TA贡献1765条经验 获得超5个赞
Answer in C#:
A first line is a number of case.
The second line is a value.
Example :
Line1: 3
Line2: 10,55,20
Example 2:
Line1: 4
Line2: 10,55,20, 44
代码:
using System;
class sasikumarv{
public static void Main()
{
var read = Console.ReadLine();
int T= Convert.ToInt32(read);
var line = Console.ReadLine();
var numbers = line.Split(' ');
if(first>=1 && first<=10)
{
for(int cnt=0;cnt<T;cnt++)
{
for(int i = 1; i <= Convert.ToInt32(numbers[cnt]); i++)
{
if (i % 15 == 0)
Console.WriteLine("FizzBuzz" + " ");
else if (i % 3 == 0)
Console.WriteLine("Fizz" + " ");
else if (i % 5 == 0)
Console.WriteLine("Buzz" + " ");
else
Console.WriteLine(i + " ");
}
}
}
}
}
添加回答
举报