C#(.NET)面试题:做一个能自定定义输入命令的表格程序

简介: C#(.NET)面试题:做一个能自定定义输入命令的表格程序

这个试题面试的公司是某一上市公司。

试题是英文的(后面给出翻译):

you're given a task of writing a simple program where an and user will be able performing some basic spreadsheet operation(i.e. sum)

in a nutshell,the program should work as follows:

  • create a new spread shee
  • add number in different cells and perform some caculation on top of specific row or column
  • Quit


您可以编写一个简单的程序,其中一个和用户可以执行一些基本的电子表格操作(即SUM)。


简而言之,程序的工作方式如下

  • 能够创建新的电子表格
  • 在不同的单元格中添加数字,并在特定的行或列的顶部执行一些计算
  • 能够退出

Commamd 命令 Description 描述
C w h

should create a new spread sheet of width w and height h(i.e. the spreadsheet can hold w * h amount of cells)

应该创建一个宽度为w、高度为h的新电子表格(即电子表格可以容纳w*h的单元格数量)

N x1 y1 v1

should insert a number in specificed cell(x1,y1)

应在特定单元格中插入数字(x1,y1)

S x1 y1 x2 y2 x3 y3

should perform sum on top of all cells from x1 y1 to x2 y2 and store the result in x3 y3

应该在x1 y1到x2 y2的所有单元格上执行求和,并将结果存储在x3 y3中

Q

Should quit the program

退出程序

 

you can write a console or browser application that will pro vide the interactive user experience in c# or javascript,mentioned in the problem statement

you can consider your choice of testing framework

assume each cell will allocate at most 3 characters,thus numbers given here should be right justified accordingly

please provide a read me document or text file,along with the submitted code,detailing instruction of running the application and tests,design considerations etc

the code is required to be hosted in apeivate repository in bitbucket. Bitbucket allows user create free private respositories


您可以编写一个控制台或浏览器应用程序,以提供C# 或javascript中提到的交互式用户体验

您可以考虑选择测试框架

假设每个单元格最多分配3个字符,因此此处给出的数字应相应地右对齐。

请提供一份自述文件或文本文件,连同提交的代码、运行应用程序和测试的详细说明、设计注意事项等。

代码需要托管在BitBucket中的Apeivate存储库中。BitBucket允许用户创建免费的私人呼吸

 

besides the code quality,we'll also check how you commit code(i.e. frequency,quality of commit comment,quality unit of code being committed etc)

the following assessment criteria's will be considered on the submitted code:

code quality(whether its following best practices with regard to design principles,patterns,algorithms)

if the program is validating user data,and considering edge cases

is the program is tested accordingly


除了代码质量,我们还将检查您如何提交代码(即频率、提交注释的质量、提交的代码的质量单位等)

提交的代码将考虑以下评估标准:

代码质量(是否遵循设计原则、模式、算法方面的最佳实践)

如果程序正在验证用户数据,并考虑边缘情况

程序是否被相应地测试


就是说设计一个程序,使程序能够捕获用户输入,并且能够创建表格、处理单元格内容。当然这不是指Excel表格。


微信图片_20220501152040.png


要求是:

  • 能够处理以上列出的命令,完成功能逻辑。并且能够识别、处理无效指令
  • 避免出现异常,能够正确处理程序
  • 能够限制表格边界
  • 正确处理用户指令,用户输入的指令错误、超出预设范围等时,程序不出现崩溃。
  • 每个单元格只能有三个字符,不足三个字符时,左对齐


我实现的程序如下(gif动图)


微信图片_20220501152043.gif


有效控制和正确识别指令


微信图片_20220501152048.gif


项目地址:

https://github.com/whuanle/GenerateTable


笔者项目上传的 ReadMe.MD 文件是英文的,翻译一下就好。主要问题也在文章这里说明了。


项目使用了 StyleCop.Analyzers 代码质量审查工具,对程序的代码质量进行审查。

无论你怎么输入,不会因为你的错误指令使程序崩溃。


使用高内聚、低耦合的思路进行设计,避免函数式、If/else式编程。


微信图片_20220501152053.png

 

要求:

VS 2017

.Net Core (最新 2.2,可支持不同版本)

 

相关文章
|
16天前
|
数据可视化 网络协议 C#
C#/.NET/.NET Core优秀项目和框架2024年3月简报
公众号每月定期推广和分享的C#/.NET/.NET Core优秀项目和框架(每周至少会推荐两个优秀的项目和框架当然节假日除外),公众号推文中有项目和框架的介绍、功能特点、使用方式以及部分功能截图等(打不开或者打开GitHub很慢的同学可以优先查看公众号推文,文末一定会附带项目和框架源码地址)。注意:排名不分先后,都是十分优秀的开源项目和框架,每周定期更新分享(欢迎关注公众号:追逐时光者,第一时间获取每周精选分享资讯🔔)。
|
30天前
|
SQL 安全 API
C# 读取Word表格到DataSet
C# 读取Word表格到DataSet
|
1月前
|
存储 C#
C#学习系列相关之数组(一)---数组的定义与使用
C#学习系列相关之数组(一)---数组的定义与使用
|
1月前
|
SQL 数据库 C#
C# .NET面试系列十一:数据库SQL查询(附建表语句)
#### 第1题 用一条 SQL 语句 查询出每门课都大于80 分的学生姓名 建表语句: ```sql create table tableA ( name varchar(10), kecheng varchar(10), fenshu int(11) ) DEFAULT CHARSET = 'utf8'; ``` 插入数据 ```sql insert into tableA values ('张三', '语文', 81); insert into tableA values ('张三', '数学', 75); insert into tableA values ('李四',
65 2
C# .NET面试系列十一:数据库SQL查询(附建表语句)
|
1月前
|
开发框架 算法 搜索推荐
C# .NET面试系列九:常见的算法
#### 1. 求质数 ```c# // 判断一个数是否为质数的方法 public static bool IsPrime(int number) { if (number < 2) { return false; } for (int i = 2; i <= Math.Sqrt(number); i++) { if (number % i == 0) { return false; } } return true; } class Progr
58 1
|
9天前
|
开发框架 前端开发 JavaScript
采用C#.Net +JavaScript 开发的云LIS系统源码 二级医院应用案例有演示
技术架构:Asp.NET CORE 3.1 MVC + SQLserver + Redis等 开发语言:C# 6.0、JavaScript 前端框架:JQuery、EasyUI、Bootstrap 后端框架:MVC、SQLSugar等 数 据 库:SQLserver 2012
|
30天前
|
存储 SQL C#
C# 读取二维数组集合输出到Word预设表格
C# 读取二维数组集合输出到Word预设表格
|
1月前
|
Java C# 开发工具
第一个C#程序
第一个C#程序
12 0
|
1月前
|
存储 开发框架 .NET
C# 面试题及答案整理,最新面试题
C# 面试题及答案整理,最新面试题
44 0
|
1月前
|
存储 C# 索引
C#学习相关系列之数据类型类的定义(一)
C#学习相关系列之数据类型类的定义(一)