当前位置:网站首页>C exercise. Class list plus records, display records and clear records
C exercise. Class list plus records, display records and clear records
2022-06-26 19:27:00 【laocooon】
using System;
namespace Enemy list
{
internal class Program
{
static void Main(string[] args)
{
NameList nList = new NameList();
nList.Add(" Cold ice ");
nList.Add(" galen ");
nList.Add(" spider ");
nList.List();// Show
nList.Add(" faker ");
nList.Add(" The bomb people ");
nList.Add(" The tree ");
nList.Add(" Female gun ");
nList.Add(" The goddess of war ");
nList.Add(" Swift scout ");
nList.Add(" Chief Tauren ");
nList.List();// Show
nList.Add(" Night hunter ");
nList.Add(" Don't put out the thunder ");
nList.Add(" The shadow of the blade ");
nList.List();// Show
nList.Clear();// Empty
nList.List();// Show
Console.ReadKey();
}
}
class NameList
{
private const int MAX = 10;// Maximum length
private string[] Name=new string[10];
private int cnt;// Actual length
public NameList()
{
cnt = 0;
}
public void Add(string name)// Increase personnel
{
if (cnt == MAX)// Represents the full condition
{
// The data moves to the left as a whole
for(int i=0;i<MAX-1;i++)
{
Name[i] = Name[i+1];
}
Name[MAX - 1] = name;
}
else// Dissatisfaction
{
Name[cnt] = name;
cnt++;
}
Console.WriteLine(" Add personnel information :" + name);
}
public void List()// Show all people
{
Console.WriteLine(" The number of people whose names are displayed is :"+cnt.ToString());
for (int i = 0; i < cnt; i++)
{
Console.WriteLine(Name[i]);
}
}
public void Clear()// Empty all personnel
{
Console.WriteLine(" Cleared the list :");
for (int i = 0; i < cnt; i++)
{
Name[i] = "";
}
cnt = 0;
}
}
}边栏推荐
- stm32和电机开发(直流有刷电机和步进电机)
- 微信小程序 uniapp 左滑 删除 带删除icon
- Project practice 5: build elk log collection system
- Development principle analysis and source code of dapp-lp single and dual currency liquidity pledge mining system
- Vscode 基础必备 常用插件
- 50 lines of code to crawl TOP500 books and import TXT documents
- 【Mysql系列】工作常用sql集锦(持续更新)
- Some cold knowledge about QT database development
- Tree array
- 成功解决之Jenkins报错:The goal you specified requires a project to execute but there is no POM
猜你喜欢

Preliminary analysis of serial port printing and stack for arm bare board debugging

商品秒杀系统

Wechat applet uniapp left slide delete with Delete Icon

Some cold knowledge about QT database development

Feign远程调用

xlua获取ugui的button注册click事件

品达通用权限系统(Day 1~Day 2)
![[recommended collection] these 8 common missing value filling skills must be mastered](/img/ab/353f74ad73ca592a3f97ea478922d9.png)
[recommended collection] these 8 common missing value filling skills must be mastered

限流设计及实现

Project practice 5: build elk log collection system
随机推荐
Filebeat安装及使用
問題解决:虛擬機無法複制粘貼文件
为什么我不推荐去SAP培训机构参加培训?
Project practice 6: distributed transaction Seata
Feign远程调用
成功解决之idea引用Lombok的@Slf4j后无法正常使用log
Commodity seckill system
8VC Venture Cup 2017 - Final Round C. Nikita and stack
JS mobile terminal touch screen event
Basic and necessary common plug-ins of vscade
How to create and enforce indexes
Reading notes: process consulting III
Project practice 5: build elk log collection system
To: Apple CEO Cook: great ideas come from constantly rejecting the status quo
品达通用权限系统(Day 1~Day 2)
Summary of several common UML diagrams
知识点总结
SSO微服务工程中用户行为日志的记录
黑客用机器学习发动攻击的九种方法
Tiktok practice ~ search page ~ video details