当前位置:网站首页>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;
}
}
}边栏推荐
- 网上办理中金财富开户安全吗?
- uni-app使用canvas绘制二维码
- The eigen library calculates the angle between two vectors
- Tiktok practice ~ homepage video ~ pull-down refresh
- Redis single sign on system + voting system
- Record of user behavior log in SSO microservice Engineering
- MySQL recharge
- Solidity - contract inheritance sub contract contains constructor errors and one contract calls the view function of another contract to charge gas fees
- Six necessary threat tracking tools for threat hunters
- Invocation failed Unexpected end of file from server
猜你喜欢
随机推荐
JS mobile terminal touch screen event
Micro service single sign on system (SSO)
Current limiting design and Implementation
Project practice 5: build elk log collection system
Tiktok practice ~ sharing module ~ short video download (save to photo album)
MySQL recharge
ImageView, glide load long picture (glide load picture)
Convex hull problem
The successfully resolved idea cannot use the log normally after referencing Lombok's @slf4j
Request method 'POST' not supported
redis 基础知识
抖音实战~分享模块~生成短视频二维码
Record of user behavior log in SSO microservice Engineering
Some cold knowledge about QT database development
Project practice 4: user login and token access verification (reids+jwt)
抖音实战~搜索页面~视频详情
Reading notes: process consulting III
抖音实战~分享模块~短视频下载(保存到相册)
品达通用权限系统(Day 3~Day 4)
深度学习之Numpy篇








