求助5个问答题!急
- C# code
1、HashTable、SortList 、Stack、Queue之间的概念与异同2、文件操作的命名空间,,主要成员driver与driverinfo,File与FileInfo,Directory与DirectoryInfo,能说明其异同。哪个可实例化,那些不可以3、XML操作,使用XmlDocument与XmlTextReader 、XmlTextWrite读写XML文档,能写出这几个类的名称,并且简述其主要功能。4、在项目中创建一个XML文件,文件的结构自定义,利用XmlElement对象来修改该文档,为该文档增加一个子节点。5、熟悉ASCII码之间比较大小,熟悉使用选择排序或者冒泡排序对数字进行排序。
[解决办法]
都是很基础的东西,建议看看《C#高级编程》
[解决办法]
添加一个结点:
XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load(Server.MapPath("data.xml"));
XmlNode root=xmlDoc.SelectSingleNode("Employees");//查找<Employees>
XmlElement xe1=xmlDoc.CreateElement("Node");//创建一个<Node>节点
xe1.SetAttribute("genre","张三");//设置该节点genre属性
xe1.SetAttribute("ISBN","1-1111-1");//设置该节点ISBN属性
XmlElement xesub1=xmlDoc.CreateElement("title");
xesub1.InnerText="C#入门帮助";//设置文本节点
xe1.AppendChild(xesub1);//添加到<Node>节点中
XmlElement xesub2=xmlDoc.CreateElement("author");
xesub2.InnerText="高手";
xe1.AppendChild(xesub2);
XmlElement xesub3=xmlDoc.CreateElement("price");
xesub3.InnerText="158.3";
xe1.AppendChild(xesub3);
root.AppendChild(xe1);//添加到<Employees>节点中
xmlDoc.Save ( Server.MapPath("data.xml") );
-------------------------------------------
结果:在xml原有的内容里添加了一个结点,内容如下,
<?xml version="1.0"?>
<Employees>
<Node genre="李赞红" ISBN="2-3631-4">
<title>CS从入门到精通</title>
<author>候捷</author>
<price>58.3</price>
</Node>
<Node genre="李赞红" ISBN="2-3631-4">
<title>CS从入门到精通</title>
<author>候捷</author>
<price>58.3</price>
</Node>
<Node genre="张三" ISBN="1-1111-1">
<title>C#入门帮助</title>
<author>高手</author>
<price>158.3</price>
</Node>
</Employees>
[解决办法]
- C/C++ code
冒泡排序的例子#include<iostream>using namespace std;int main() { int a[]={12,22,36,15,99,44,1,2,3,5,57}; int i=0; while(i<10) { int temp=0; if(a[i]>a[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; i=0; continue; } i++; } for(int i=0;i<=10;i++) { cout<<a[i]<<endl; } system("pause"); }