c#金雪云课后题参考答案

上传人:第*** 文档编号:33917861 上传时间:2018-02-19 格式:DOC 页数:46 大小:324.50KB
返回 下载 相关 举报
c#金雪云课后题参考答案_第1页
第1页 / 共46页
c#金雪云课后题参考答案_第2页
第2页 / 共46页
c#金雪云课后题参考答案_第3页
第3页 / 共46页
c#金雪云课后题参考答案_第4页
第4页 / 共46页
c#金雪云课后题参考答案_第5页
第5页 / 共46页
点击查看更多>>
资源描述

《c#金雪云课后题参考答案》由会员分享,可在线阅读,更多相关《c#金雪云课后题参考答案(46页珍藏版)》请在金锄头文库上搜索。

1、C#教程习题参考答案第一章(1) .NET Framework 是平台,Visual Studio.NET 是集成开发环境,C# 是一种.NET 平台下的开发语言(2) 易于掌握、支持跨平台、面向对象、与 XML 相融合(3) 组织资源、避免命名冲突(4) (5) 第二章上机练习(1) .(2)using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 上机练习2class Programstatic void Main(string args)string myText

2、;int Other = 0;int numLetters = 0;int numDigits = 0;char ch;int index = 0;Console.WriteLine(请输入要分析的字符串);myText = Console.ReadLine().ToUpper();while (index b)tempmin = b;if (tempmin c)tempmin = c;if (tempmin d)tempmin = d;return tempmin;public static void Main()Console.WriteLine(Please input four num

3、ber:);int x1 = Convert.ToInt32(Console.ReadLine();int x2 = Convert.ToInt32(Console.ReadLine();int x3 = Convert.ToInt32(Console.ReadLine();int x4 = Convert.ToInt32(Console.ReadLine();Console.WriteLine(The Max Number is :0, max(x1, x2, x3, x4);Console.WriteLine(The Min Number is :0, min(x1, x2, x3, x4

4、);Console.ReadLine();(5)using System;class Testpublic static int addfor()int sum = 0;for(int i = 0 ; i arri,k)flag=1;/* 鞍点存在,查找是否有多个鞍点 */if(flag=0)/* 找出鞍点个数并打印出来 */for(j=0;j 0)ai = b % 2;b /= 2;i+;j+; Console.WriteLine(The result is :);for (k = j - 1; k = 0; k-)Console.WriteLine(0, ak);Console.ReadL

5、ine();(6) using System;using System.Collections;using System.Collections.Generic;class friendstring name=;string telephone=;string group=;public string Namegetreturn name;setname = value;public string Telephonegetreturn telephone;settelephone = value;public string Groupget return group;setgroup = va

6、lue;public friend(string n,string t,string g)name = n;telephone = t;group = g;public friend(string n)name = n;telephone = ;group = ;public void Display()Console.WriteLine(-);Console.WriteLine(姓名:0n,this.Name);Console.WriteLine(电话:0n,this.telephone);Console.WriteLine(组:0n,this.group);class telephoneb

7、ookprivate ArrayList tele;public telephonebook()this.tele = new ArrayList();public void Add(friend f)this.tele.Add(f);public void Delete(string na)friend temp=null; foreach (friend f in this.tele)if (friend)f).Name = na)temp = f;if(temp != null)this.tele.Remove(temp);public void Edit(string na)strin

8、g name, tele, group;Console.WriteLine(请输入修改后的名称:);name = Console.ReadLine();Console.WriteLine(请输入修改后的电话:);tele = Console.ReadLine();Console.WriteLine(请输入修改后的组:);group = Console.ReadLine();this.Delete(na);friend temp = new friend(name, tele, group);this.tele.Add(temp);public friend SearchByName(strin

9、g na)foreach (friend f in this.tele)if (f.Name = na)return f;return null;public friend SearchByTele(string tel)foreach (friend f in this.tele)if (f.Telephone = tel)return f;return null;public void display()foreach (friend f in this.tele) f.Display();class MainClasspublic static void Main(string args

10、)telephonebook tb = new telephonebook();friend zangsan = new friend(zs, 123, jiaren);zangsan.Display();tb.Add(zangsan);friend temp = tb.SearchByTele(123);if (temp != null)temp.Display();elseConsole.WriteLine(查无此人!);tb.display();Console.ReadLine();习题1、选择题(1) D (2) C (3) A (4) ABC (5) C2、填空题(1) Sort()

11、 (2) 抛出异常、集合已修改;可能无法执行枚举操作。(3) 获取头部元素数据(4) Peek 方法仅获取栈顶元素数据,Pop 方法删除栈顶元素(5) 实现 System.IEnumerable 接口或实现集合模式(6) 名值对(7) SortedList 中的 Key 数组排好序的第五章上机练习(1) (2) class studentpublic string name;private int age;private int heigh;private string grade;public student()this.name = ;this.age = 18;this.heigh =

12、180;this.grade = 0604;public student(string na, int a, int h, string g)this.grade = g;this.name = na;this.heigh = h;this.age = a;student()(3)using System;using System.Collections.Generic;class Employeeprivate string name;private string ID;public static float TotalSalary;/定义实例构造函数,用来初始化实例中成员public Em

13、ployee()this.name = ;this.price = 0000;public Employee(string n,string i)this.name = n;this.ID = i;/定义静态构造函数static Employee()TotalSalary = 0;/定义析构函数Employee()public void printName()Console.WriteLine(this.name);(4)using System;using System.Collections.Generic;class Employeeprivate string name;private

14、 string ID;public static float TotalSalary;private float Salary;/定义实例构造函数,用来初始化实例中成员public Employee()this.name = ;this.ID = 0000;this.Salary = 0;public Employee(string n,string i,float s)this.name = n;this.ID = i; this.Salary =s;TotalSalary += this.Salary;/定义静态构造函数static Employee()TotalSalary = 0;/定

15、义析构函数Employee()public void printName()Console.WriteLine(this.name);public static void DisplayTotalSalary()Console.WriteLine(总薪水为:0,TotalSalary);(5) using System;using System.Collections.Generic;class Accountprivate string ID;private string PSW;private string Name;private float Balance;public static float TotalBalance;/定义实例构造函数,用来初始化实例中成员public Account(string i, string p, string n, float b)this.Balance = b;this.ID = i;this.Name = n;this.PSW = p;TotalBal

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号