题目
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的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1with的复合结构作状语时,同时表示将来和被动时,逻辑谓语为什么还是用了不定式的主动式?
- 2如何利用反函数求其原函数的值域
- 3英语翻译:给我们讲个故事,What __________________________________?
- 41.用单价每千克6元和每千克11元的水果糖配制成单价是每千克8元的混合型水果糖,这两种糖配制的比例是多少?
- 5on your way somewhere eles
- 6餐饮预定员翻译成英文怎么说
- 7已知集合A={x|x2-ax+a2-19=0},B={x|x2-5x+6=0},C={x|x2+2x-8=0} (1)若A∩B=A∪B,求a的值; (2)若A∩B=A∩C≠∅,求a的值.
- 8伟人细胞中“细胞”一词是什么意思
- 9《山中访友》这一篇课文为什么以《山中访友》为题
- 10abcd是HCl BaCl2 AgNO3 Na2CO3四种溶液中的一种,现将它们两两混合,现象如下表所示
热门考点
- 16年级所有数学公式概念(人教版)要全!
- 2细胞中细胞壁核细胞核的关系是什么?
- 3要 碳,铁,蜡,镁,文字表达式的元素符号 如红磷的:p+o2-点燃-p2o5 这种的
- 4第八届中国杭州西湖博览会在杭州市人民政府承办,为期六个月.这段话是不是病句
- 5物理;猎豹是动物世界的短跑冠军,速度可达28m/s,min能跑多远求大神帮助
- 6we can help these individuals.和we can help these people有不同吗?
- 7用夸张手法表达,如:富得(流油) 容易得( )心眼小得( )快!
- 8含有ow、ou发[au]的单词
- 9嫦娥一号”月球探测器在环绕月球运行过程中,设探测器运行的轨道半径为r,运行速率为v,当“嫦娥一号”在飞越月球上一些环形山中的质量密集区上空时( ).
- 100.45:0.9求最简整数比,求比值