//不知道思路了,请问这个怎么实现呢,还要用到arraylist!using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;namespace ConsoleApplication17
{
class stu
{
public object ArrayList() ;
public int age;
public string name;
public stu(string name, int age)
{
this.age = age; this.name = name;
}
}
class gl
{
stu[] ren=new stu[10000];
int id = 0;
public void tj(string name,int age)
{//添加学生
ren[id] = new stu(name, age);
Console.WriteLine("姓名:{0} 年龄:{1}",ren[id].name,ren[id].age);
} public void sc(int id)
{//删除
} public void xgxx(int id, string name)
{//修改学生信息 } public void cx1(string name)
{//查询学生信息(姓名)
} public void cx(int age)
{//查询学生信息(年龄)
}
} class aaa
{
} class Program
{
static void Main(string[] args)
{
//stu e = new stu();
//e.name = "";
//e.age = 18;
gl c = new gl(); ArrayList abc = new ArrayList();
abc.Add(c.tj);
Console.WriteLine("添加按1、删除按2、查询按3、修改按4、退出按5");
int a = Convert.ToInt32(Console.ReadLine());
while (a < 5)
{ if (a == 1)
{
Console.WriteLine("输入姓名");
string xm = Console.ReadLine();
Console.WriteLine("输入年龄");
int nl = Convert.ToInt32(Console.ReadLine());
c.tj(xm, nl); }
if (a == 2)
{
Console.WriteLine("输入年龄");
int id = Convert.ToInt32(Console.ReadLine());
c.sc(id); }
if (a == 3)
{
Console.WriteLine("按姓名查询 1 、按年龄查询 2");
int d = Convert.ToInt32(Console.ReadLine());
if (d == 1)
{
Console.WriteLine("输入姓名");
string name = Console.ReadLine();
c.cx1(name);
}
if (d == 2)
{
Console.WriteLine("输入年龄");
int id = Convert.ToInt32(Console.ReadLine());
c.cx(id);
}
if (d != 1 && d != 2)
{
Console.WriteLine("输入有误");
}
}
if (a == 4)
{
Console.WriteLine("输入年龄");
int id = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("输入姓名");
string name = Console.ReadLine();
c.xgxx(id, name);
}
Console.WriteLine("添加 1 \n删除 2 \n查询 3\n修改 4\n退出 5");
a = Convert.ToInt32(Console.ReadLine());
}
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Collections;namespace ConsoleApplication17
{
class stu
{
public object ArrayList() ;
public int age;
public string name;
public stu(string name, int age)
{
this.age = age; this.name = name;
}
}
class gl
{
stu[] ren=new stu[10000];
int id = 0;
public void tj(string name,int age)
{//添加学生
ren[id] = new stu(name, age);
Console.WriteLine("姓名:{0} 年龄:{1}",ren[id].name,ren[id].age);
} public void sc(int id)
{//删除
} public void xgxx(int id, string name)
{//修改学生信息 } public void cx1(string name)
{//查询学生信息(姓名)
} public void cx(int age)
{//查询学生信息(年龄)
}
} class aaa
{
} class Program
{
static void Main(string[] args)
{
//stu e = new stu();
//e.name = "";
//e.age = 18;
gl c = new gl(); ArrayList abc = new ArrayList();
abc.Add(c.tj);
Console.WriteLine("添加按1、删除按2、查询按3、修改按4、退出按5");
int a = Convert.ToInt32(Console.ReadLine());
while (a < 5)
{ if (a == 1)
{
Console.WriteLine("输入姓名");
string xm = Console.ReadLine();
Console.WriteLine("输入年龄");
int nl = Convert.ToInt32(Console.ReadLine());
c.tj(xm, nl); }
if (a == 2)
{
Console.WriteLine("输入年龄");
int id = Convert.ToInt32(Console.ReadLine());
c.sc(id); }
if (a == 3)
{
Console.WriteLine("按姓名查询 1 、按年龄查询 2");
int d = Convert.ToInt32(Console.ReadLine());
if (d == 1)
{
Console.WriteLine("输入姓名");
string name = Console.ReadLine();
c.cx1(name);
}
if (d == 2)
{
Console.WriteLine("输入年龄");
int id = Convert.ToInt32(Console.ReadLine());
c.cx(id);
}
if (d != 1 && d != 2)
{
Console.WriteLine("输入有误");
}
}
if (a == 4)
{
Console.WriteLine("输入年龄");
int id = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("输入姓名");
string name = Console.ReadLine();
c.xgxx(id, name);
}
Console.WriteLine("添加 1 \n删除 2 \n查询 3\n修改 4\n退出 5");
a = Convert.ToInt32(Console.ReadLine());
}
}
}
}
首先你要确定数据存储区:例如可以用哈希表
然后从主函数开始,一直到最后,都围绕这这张哈希表来进行操作,这是一条主线你不会参加了什么培训吧?
恭喜你,答对了。我做出来了,呵呵。
你事直接飞过来得吗?
呵呵……