Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
csharp basic exercises: Counting like a child. [difficulty: Level 1]:
My best friend has a lovely 3-year-olds. Every time I go to visit them, she hopes to show off her Counting technology impress me. So far, she can count N
. However, she counted a question : she always forget the even you in this task is to be able to count exercises like her for convenience, let's put these numbers, she was able to count on an array Good luck mate...!
When 0 is passed, return []
.
Example:
kidoCount(10)=>应返回[1,3,5,7,9]
kidoCount(9)=>应返回[1,3,5,7,9]
kidoCount(0)=>应返回[]
Programming objectives:
public static class Kata {
public static int[] KidoCount(int n) {
// code here
}
}
8
Test sample:
namespace Solution {
using NUnit.Framework;
using System;
[TestFixture]
public class KataTest {
[Test]
public void ExampleTests() {
Assert.AreEqual(new int[] { 1, 3, 5, 7, 9 }, Kata.KidoCount(10));
.( [] { , , , , , }, .(11));
}
}
14
Best answer (multiple solutions):
More related topics:
Disclaimer
This blog All programming topics and answers were collected from the Internet, users are mainly used for study and reference, if any violation of your rights, please contact the administrator to delete, thank
entitled to collect https://www.codewars.com/
HTTPS: / /www.codewars.com/kata/counting-like-a-kid