Complete The Pattern #1
2024-10-18 18:24:27
Complete The Pattern #1
Task:
You have to write a function pattern which creates the following pattern upto n number of rows.
- If the Argument is 0 or a Negative Integer then it should return ""
Pattern:
1
22
333
....
.....
nnnnnn
Note: There are no spaces in the pattern
Hint: Use \n in string to jump to next line
无形装逼最为致命,居然喜欢上用Linq了
using System;
using System.Linq; public class Kata
{
public string Pattern(int n)
{
// Happy Coding ^_^
string result = string.Empty;
if (n > )
{
result = string.Join(Environment.NewLine, Enumerable.Range(, n).Select(item => string.Join(string.Empty, Enumerable.Repeat(item, item))));
}
return result;
}
}
最新文章
- spring boot 添加拦截器
- maven核心,pom.xml详解(转)
- 向 Git 服务器添加 SSH 公钥
- Apache Spark技术实战之4 -- 利用Spark将json文件导入Cassandra
- SqlSever基础 Upper函数 返回字符串的大写形式
- Nginx安装(zhuan)
- PAT1099
- [Linux]学习笔记(4)-su及passwd的用法介绍
- pod setup 报CocoaPods was not able to update the `master` repo 错误解决办法
- Android 拨号器的简单实现
- 实现动态的XML文件读写操作
- windows 下编译php扩展库pecl里的扩展memcache
- [Usaco2015 Jan]Grass Cownoisseur Tarjan缩点+SPFA
- 用node搭建简单的静态资源管理器
- Python基础知识拾遗
- linux僵尸进程
- Keras官方中文文档:常见问题与解答
- js 学习之路6: if...else...条件语句的使用
- Doctrine2-基础概念
- Leetcode 存在重复元素 (219,220)