csharp基础练习题:大数字* 数字【难度:1级】:
你有一个
大量的类型字符串
和
一个整数
,
写一个函数如何计算
LargeNumber
和
数字
的乘法并返回字符串中的结果,
LargeNumber> 0; 0 <=数字<10;
0 <= LargeNumber.Length <= 100
编程目标:
public class Kata
{
public static string multiplication(string largeNumber, int digit)
{
// your code
return "";
}
}
测试样例:
namespace Solution
{
using NUnit.Framework;
using System;
[TestFixture]
public class KataTests
{
[Test]
Assert.AreEqual("1452",Kata.multiplication("1452",1));
Assert.AreEqual("2904",Kata.multiplication("1452",2));
Assert.AreEqual("246913578246913578246913578246913578",Kata.multiplication("123456789123456789123456789123456789",2));
Assert.AreEqual("2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018",Kata.multiplication("1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009",2));
Assert.AreEqual("5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000115360090",Kata.multiplication("1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023072018",5));
Assert.AreEqual("29207927925",Kata.multiplication("3245325325",9));
Assert.AreEqual("59259259260",Kata.multiplication("9876543210",6));
最佳答案(多种解法):
更多关联题目:
csharp基础练习题:Delta Bits【难度:1级】–景越C# 经典编程题库,不同难度C# 练习题,适合自学C# 的新手进阶训练
csharp进阶练习题:整数深度【难度:2级】–景越C# 经典编程题库,不同难度C# 练习题,适合自学C# 的新手进阶训练
csharp进阶练习题:复活节【难度:2级】–景越C# 经典编程题库,不同难度C# 练习题,适合自学C# 的新手进阶训练
免责申明
本博客所有编程题目及答案均收集自互联网,主要用于供网友学习参考,如有侵犯你的权益请联系管理员及时删除,谢谢
题目收集至https://www.codewars.com/
https://www.codewars.com/kata/largenumber-star-digit