题目
give me an answer
class Program
{
static void Main(string[] args)
{
LinkedList list = new LinkedList();
list.AddFirst(10);
list.AddLast(20);
list.AddLast(30);
list.AddLast(40);
The above program is incomplete,please complete the above program to perform following operations on linked list,the operations to be performed are:
i.Display total number of nodes into the linked list
ii.Add value :25 after 20.
iii.Add value 5 before 10
iv.Check that the list contains value 30,if contains display a message “30 is into the linked list”
v.Display the values of all the nodes from the linked list.
class Program
{
static void Main(string[] args)
{
LinkedList list = new LinkedList();
list.AddFirst(10);
list.AddLast(20);
list.AddLast(30);
list.AddLast(40);
The above program is incomplete,please complete the above program to perform following operations on linked list,the operations to be performed are:
i.Display total number of nodes into the linked list
ii.Add value :25 after 20.
iii.Add value 5 before 10
iv.Check that the list contains value 30,if contains display a message “30 is into the linked list”
v.Display the values of all the nodes from the linked list.
提问时间:2020-11-10
答案
using System;
using System.Collections.Generic;
using System.Text;
namespace LinkedListDemo
{
class Program
{
static void Main(string[] args)
{
LinkedList<int> list = new LinkedList<int>();
list.AddFirst(10);
list.AddLast(20);
list.AddLast(30);
list.AddLast(40);
//i. Display total number of nodes into the linked list
Console.WriteLine("Total number of nodes:{0}", list.Count);
//ii. Add value : 25 after 20.
list.AddAfter(list.Find(20), 25);
//iii. Add value 5 before 10
list.AddBefore(list.Find(10), 5);
//iv. Check that the list contains value 30, if contains display a message “30 is into the linked list”
if (list.Contains(30)) {
Console.WriteLine("30 is into the linked list");
}
//v. Display the values of all the nodes from the linked list.
foreach (int value in list) {
Console.Write("{0} ", value);
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Text;
namespace LinkedListDemo
{
class Program
{
static void Main(string[] args)
{
LinkedList<int> list = new LinkedList<int>();
list.AddFirst(10);
list.AddLast(20);
list.AddLast(30);
list.AddLast(40);
//i. Display total number of nodes into the linked list
Console.WriteLine("Total number of nodes:{0}", list.Count);
//ii. Add value : 25 after 20.
list.AddAfter(list.Find(20), 25);
//iii. Add value 5 before 10
list.AddBefore(list.Find(10), 5);
//iv. Check that the list contains value 30, if contains display a message “30 is into the linked list”
if (list.Contains(30)) {
Console.WriteLine("30 is into the linked list");
}
//v. Display the values of all the nodes from the linked list.
foreach (int value in list) {
Console.Write("{0} ", value);
}
Console.ReadKey();
}
}
}
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1《母爱的力量》阅读理解,短文在下.
- 2已知ab两地 相距300千米,甲乙两车从a地同时出发驶向b地,甲车车速为每小时60千米,乙车速度为每小时140千米,甲车出发后在休息了一小时,乙车到达b地后马上返回a地,途中与甲车相遇.问:乙车从出发
- 3① 一块正方形菜地的边长是2.4米,其中十分之八种酉红柿,种酉红柿的面积是多少平方米?
- 4两个质数,它们的和与差也都是质数这两个数是几和几?
- 5若A=0.000…025,B=0.000…04,则A×B=(),A÷B=() 100个
- 6Law of pertaining to the lapse of Sentence 求翻译
- 7《海滨仲夏夜》是作者峻青.怎么改病句?
- 8英语翻译
- 9在所有的有机物中,碳原子都是四价的吗
- 10人生路上我们都是新手 作文 300字
热门考点
- 1人类在探索自然规律的过程中,总结了许多科学研究方法:“控制变量”、“类比”、“模型”等,下面两个例子都运用了上述()的方法说明分子也具有动能和势能.
- 2It is my birthday today.改为一般疑问句
- 3I like to wear a new yellow dress.Kate likes to wear a red skirt on her birthday翻译.
- 4The teacher made him _(stay)in the classroom after school.
- 5若斜率为1的直线与圆(x-1)^2(y+1)^2=2相切,则该直线的方程为
- 6我的梦想职业 教师 作文
- 7功率相等的两辆汽车,走完相同的路程所用的时间之比为5:2,则两车牵引力之比为_,做功之比为_;若两汽车的功率之比为2:3,完成相同的功所用的时间之比为_.
- 8静止在水平地面上的正立方体木块的边长为a.质量m.
- 9我的小小心愿或意想不到的事 作文
- 10若a2+b2+a-2b+5/4=0,则a−ba+b=_.