csharp基础练习题:猫年,狗年【难度:0级】:
习题任务
我有一只猫和一只狗.
我让他们在同一时间,小猫/小狗.这是humanYears
年前.
现在回到各自的年龄为[humanYears
,catYears
,dogYears
]
笔记:
- humanYears> = 1
- humanYears仅整数
年猫
*15
猫年,第一年
*+ 9
猫年,第二年
*+ 4
猫年后每年对于
狗年月
*15
狗年历第一年
*+ 9
狗年第二年
*+ 5
狗年后每年对于
** ** 引用
- http://www.catster/cats-101/calculate-cat-age-in-cat-years
- http://www.slate/articles/news_and_politics/explainer/2009/05/a_dogs_life.html
如果你喜欢这个习题还有另外一个相关的一个这里
编程目标:
public class Dinglemouse {
public static int[] humanYearsCatYearsDogYears(int humanYears) {
// Your code here!
return new int[]{0,0,0};
}
}
测试样例:
namespace Solution {
using NUnit.Framework;
using System;
// TODO: Replace examples and use TDD development by writing your own tests
[TestFixture]
public class SolutionTest
{
public void One()
{
Assert.AreEqual(new int[]{1,15,15}, Dinglemouse.humanYearsCatYearsDogYears(1));
}
[Test]
public void Two()
{
最佳答案(多种解法):
点击查看答案
更多关联题目:
免责申明
本博客所有编程题目及答案均收集自互联网,主要用于供网友学习参考,如有侵犯你的权益请联系管理员及时删除,谢谢
题目收集至https://www.codewars/
https://www.codewars/kata/cat-years-dog-years
更多推荐
csharp基础练习题:猫年,狗年【难度:0级】--景越C#经典编程题库,不同难度C#练习题,适合自学C#的新手进阶训练
发布评论