当前位置:网站首页>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;
}
}
}
边栏推荐
- 两个文件 合并为第三个文件 。
- find_ path、find_ Library memo
- Selection of database paradigm and main code
- Record of user behavior log in SSO microservice Engineering
- Project practice 5: build elk log collection system
- Summary of knowledge points
- 转:苹果CEO库克:伟大的想法来自不断拒绝接受现状
- Successfully solved the problem of garbled microservice @value obtaining configuration file
- 黑客用机器学习发动攻击的九种方法
- SSO微服务工程中用户行为日志的记录
猜你喜欢
MySQL recharge
Installation and use of logstash
Vscode 基础必备 常用插件
Some cold knowledge about QT database development
Image binarization
Installation and use of filebeat
[recommended collection] these 8 common missing value filling skills must be mastered
【推荐收藏】这8个常用缺失值填充技巧一定要掌握
Record of user behavior log in SSO microservice Engineering
微服务架构
随机推荐
Selection of database paradigm and main code
WebView load pdf
品达通用权限系统(Day 1~Day 2)
Redis单点登陆系统+投票系统
Summary of alter operation in SQL
Convex hull problem
50 lines of code to crawl TOP500 books and import TXT documents
Deep learning: numpy
几种常见的UML关系图汇总
Unit test of boot
Kubernetes resource topology aware scheduling optimization
Kubernetes 资源拓扑感知调度优化
IK分词器
DAPP丨LP单双币流动性质押挖矿系统开发原理分析及源码
抖音实战~分享模块~短视频下载(保存到相册)
Why don't I recommend going to sap training institution for training?
xlua获取ugui的button注册click事件
Usage and difference between ros:: spinonce() and ros:: spin()
物联网协议的王者:MQTT
On the escape of inequality value