csharp进阶练习题:写号的扩展形式【难度:2级】--景越C#经典编程题库,不同难度C#练习题,适合自学C#的新手进阶训练

这是一篇关于C#进阶的编程练习,旨在帮助学习者提升技能。练习题要求将号码转化为扩展形式,例如将数字转换为字符串表示。文章提供了编程目标、测试样例以及最佳解答,适合C#新手进阶训练。
摘要由CSDN通过智能技术生成

csharp进阶练习题:写号的扩展形式【难度:2级】:

写在扩展表格编号

你会得到一个号码,你需要将它作为字符串返回[扩展形式(https://www.mathplacementreview.com/arithmetic/whole-numbers.php#expanded-form).例如:

expandedForm 12  - 应该返回'10 + 2'
expandedForm 42  - 应该返回'40 + 2'
expandedForm 70304  - 应该返回 '70000 + 300 + 4'

expandedForm(12); //应该返回'10 + 2'
expandedForm(42); //应该返回'40 + 2'
expandedForm(70304); //应该返回 '70000 + 300 + 4'

expanded_form(12)# 应返回'10 + 2'
expanded_form(42)# 应返回'40 + 2'
expanded_form(70304)# 如果返回 '70000 + 300 + 4'

expanded_form(12); //应该返回 "10 + 2"
expanded_form(42); //应该返回 "40 + 2"
expanded_form(70304); //应该返回 "70000 + 300 + 4"

expanded_form(12);# 应该返回'10 + 2'
expanded_form(42);# 应该返回'40 + 2'
expanded_form(70304);# 应该返回 '70000 + 300 + 4'

expandedForm(12);# 应该返回'10 + 2'
expandedForm(42);# 应该返回'40 + 2'
expandedForm(70304);# 应该返回 '70000 + 300 + 4'

Kata.expandedForm(12);# 应返回 "10 + 2"
Kata.expandedForm(42);# 应返回 "40 + 2"
Kata.expandedForm(70304);# 应返回 "70000 + 300 + 4"

Kata.ExpandedForm(12);# 应返回 "10 + 2"
Kata.ExpandedForm(42);# 应返回 "40 + 2"
Kata.ExpandedForm(70304);# 应返回 "70000 + 300 + 4"

expandedForm 12L //应该返回 "10 + 2"
expandedForm 42L //应该返回 "40 + 2"
expandedForm 70304L //应该返回 "70000 + 300 + 4"

注:所有数字将完整的数字大于0.

如果你喜欢这个习题,检查出[第2部分(https://www.codewars.com/kata/write-number-in-expanded-form-part-2)!

编程目标:

using System;
public static class Kata 
{
    public static string ExpandedForm(long num) 
    {
       throw new NotImplementedException();
    }
}


测试样例:

namespace Solution 
{
  using NUnit.Framework;
  using System;
  [TestFixture]
  public class SolutionTest
  {
    [Test]
    {
      Assert.That(Kata.ExpandedForm(12), Is.EqualTo("10 + 2"));
      Assert.That(Kata.ExpandedForm(42), Is.EqualTo("40 + 2"));
      Assert.That(Kata.ExpandedForm(70304), Is.EqualTo("70000 + 300 + 4"));
    }
  }
}


最佳答案(多种解法):

点击查看答案

更多关联题目:

csharp高级练习题:路线减少【难度:3级】–景越C# 经典编程题库,不同难度C# 练习题,适合自学C# 的新手进阶训练

免责申明

本博客所有编程题目及答案均收集自互联网,主要用于供网友学习参考,如有侵犯你的权益请联系管理员及时删除,谢谢
题目收集至https://www.codewars.com/
https://www.codewars.com/kata/write-number-in-expanded-form

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值