C#天津农学院期末复习提纲_第1页
C#天津农学院期末复习提纲_第2页
C#天津农学院期末复习提纲_第3页
C#天津农学院期末复习提纲_第4页
C#天津农学院期末复习提纲_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Visual C Net A 第 1 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 一 一 填空题 每小题填空题 每小题 1 分 分 10 小题 共小题 共 10 分 分 二 二 选择题 分为多选题与单选题 共选择题 分为多选题与单选题 共 20 分 分 一 多选题 每小题 1 5 分 10 小题 共 15 分 二 单选题 每小题 1 分 5 小题 共 5 分 三 三 判断题 每小题判断题 每小题 0 5 分 分 20 小题 共小题 共 10 分 分 四 四 问答题 每小题问答题 每小题 3 3 分 分 5 5 小题 共小题 共 1515 分 分 1 请图示说明 Microsoft NET Framework 的体系结构 2 请简述 NET Framework 类库 3 请图示描述 NET 程序的编译过程 4 请用图表的方式简 述 C 程序中的数据类型 Visual C Net A 第 2 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 5 简述 C 运算符的优先级及其结合性 优先级 1 最高 说明运算符结合性 1括号 从左到右 2自加 自减运算符 从右到左 3乘法运算符 除法运算符 取模运算符 从左到右 4加法运算符 减法运算符 从左到右 5小于 小于等于 大于 大于等于 从左到右 6等于 不等于 从左到右 从左到右 7逻辑与 static int y Visual C Net A 第 3 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 void F x 1 1 正确 y 1 2 正确 static void G x 1 3 错误 静态函数不能访问实例成员 应将 int x 变成 static int x 才可 y 1 4 正确 static void Main string args Program t new Program t x 1 5 正确 t y 1 6 错误 实例对象不能访问静态成员 应 Programer y Program x 1 7 错误 不能通过类名访问实例成员 应 t x 1 Program y 1 8 正确 2 当显性地声明 初始化一个数组表达式时 int i 3 1 正确 int x new int 3 1 2 3 2 正确 int y new int i 1 2 3 3 错误 i 变为一个常量 如 int 3 int z new int 3 1 2 3 4 4 错误 初始值与数组长度不一致 改为 int 4 3 class Mammal class Horse Mammal Trot class Whale Mammal Horse myHorse new Horse Neddy Whale myWhale myHorse 错误 不同对象赋给不同引用 把 Whale 改为 Horse Visual C Net A 第 4 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 Horse myHorse new Horse Neddy Mammal myMammal myHorse 正确 Mammal myMammal ewMammal Mammalia Horse myHorse myMammal 父类对象不能赋给子类引用 改为 Mammal myMammal myHorse Horse myHorse new Horse Neddy Mammal myMammal myHorse myMammal Breathe 正确 myMammal Trot 错误 Trot 非 Mammal 方法 改为 myHorse Trot 六 六 根据程序运行结果补充程序或写出程序运行结果根据程序运行结果补充程序或写出程序运行结果 每题 每题 4 4 分 共分 共 3 3 小题 共小题 共 1212 分 分 七 七 编程题 每小题编程题 每小题 8 8 分 分 3 3 小题 共小题 共 2424 分 分 1 请写一程序控制台程序来模拟堆栈操作 要求栈用一个类实现并编译生成 dll 文件 文件名 p5 1 2 1 cs p5 1 2 1 cs 用控制台测试程序 文件名 stackCall csstackCall cs 调用 dll 文 件以实现堆栈操作 还要写出在 Command 窗口下的编译过程 namespace p5 1 2 1 public class Stack Entry top public void Push object data top new Entry top data public object Pop if top null throw new InvalidOperationException object result top data top top next return result class Entry public Entry next public object data public Entry Entry next object data this next next this data data csc t librarycsc t library p5 1 2 1 csp5 1 2 1 cs Visual C Net A 第 5 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 using System using p5 1 2 1 class Test static void Main Stack s new Stack s Push 1 s Push 10 s Push 100 Console WriteLine s Pop Console WriteLine s Pop Console WriteLine s Pop Console Read csc r p5 1 2 1 dllcsc r p5 1 2 1 dll stackCall csstackCall cs 2 请根据下图编制程序 计算两个数的运算结果及表达式 注 不用界面编程 只 写出主要 Button 按钮的处理函数即可 private void calculateClick object sender RoutedEventArgs e try int leftHandSide int Parse lhsOperand Text int rightHandSide int Parse rhsOperand Text int answer doCalculation leftHandSide rightHandSide result Text answer ToString catch FormatException fEx Visual C Net A 第 6 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 result Text fEx Message catch OverflowException oEx result Text oEx Message catch InvalidOperationException ioEx result Text ioEx Message catch Exception ex result Text ex Message private int doCalculation int leftHandSide int rightHandSide int result 0 if addition IsChecked HasValue else if subtraction IsChecked HasValue else if multiplication IsChecked HasValue else if division IsChecked HasValue else if remainder IsChecked HasValue else throw new InvalidOperationException No operator selected return result private int addValues int leftHandSide int rightHandSide expression Text leftHandSide ToString rightHandSide ToString return leftHandSide rightHandSide private int subtractValues int leftHandSide int rightHandSide expression Text leftHandSide ToString rightHandSide ToString return leftHandSide rightHandSide Visual C Net A 第 7 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 private int multiplyValues int leftHandSide int rightHandSide expression Text leftHandSide ToString rightHandSide ToString return checked leftHandSide rightHandSide private int divideValues int leftHandSide int rightHandSide expression Text leftHandSide ToString rightHandSide ToString return leftHandSide rightHandSide private int remainderValues int leftHandSide int rightHandSide expression Text leftHandSide ToString rightHandSide ToString return leftHandSide rightHandSide private void quitClick object sender RoutedEventArgs e this Close 3 请使用委托编写一个程序实现两个字符串的连接 using System using System Collections Generic using System Linq using System Text namespace Ex DelegateCallBack public delegate string ProcessDelegate string s1 string s2 class Program static void Main string args DelegateTest test new DelegateTest string r1 test Process Text1 Text2 new ProcessDelegate test Process1 string r2 test Process Text1 Text2 new ProcessDelegate test Process2 string r3 test Process Text1 Text2 new ProcessDelegate test Process3 Console WriteLine r1 Console WriteLine r2 Console WriteLine r3 Console Read public class DelegateTest Visual C Net A 第 8 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 public string Process string s1 string s2 ProcessDelegate process return process s1 s2 public string Process1 string s1 string s2 return s1 s2 public string Process2 string s1 string s2 return s1 Environment NewLine s2 public string Process3 string s1 string s2 return s2 s1 4 请写一控制台程序打印如下显示的乘法表 1 1 1 2 1 22 2 4 3 1 33 2 63 3 9 4 1 44 2 84 3 124 4 16 5 1 55 2 105 3 155 4 205 5 25 6 1 66 2 126 3 186 4 246 5 306 6 36 7 1 77 2 147 3 217 4 287 5 357 6 427 7 49 8 1 88 2 168 3 248 4 328 5 408 6 488 7 568 8 64 9 1 99 2 189 3 279 4 369 5 459 6 549 7 639 8 729 9 81 using System using System Collections Generic using System Linq using System Text namespace 输出乘法法输出乘法法 class Program static void Main string args Multiplying mult new Multiplying Visual C Net A 第 9 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 mult print Console Read class Multiplying private int multiplier private int multiplicand public Multiplying multiplier 0 multiplicand 0 public void print for multiplicand 1 multiplicand 10 multiplicand for multiplier 1 multiplier multiplicand 1 multiplier Console Write 0 1 2 t multiplicand multiplier multiplicand multiplier Console Write n 5 请编写一个 WPF 程序 以完成随机发扑克牌的功能 运行窗口如下图所示 Visual C Net A 第 10 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 enum Suit Clubs Diamonds Hearts Spades enum Value Two Three Four Five Six Seven Eight Nine Ten Jack Queen King Ace class PlayingCard private readonly Suit suit private readonly Value value public PlayingCard Suit suit Value value this suit suit this value value public override string ToString return base ToString return String Format 0 of 1 value suit n public Suit CardSuit return this suit public Value CardValue return this value class Pack public const int NumSuit 4 public const int CardsPerSuit 13 private PlayingCard cardPack private Random randomCardSelector public Pack cardPack new PlayingCard NumSuit CardsPerSuit randomCardSelector new Random Visual C Net A 第 11 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 for Suit suit Suit Clubs suit Suit Spades suit for Value value Value Two value Value Ace value cardPack int suit int value new PlayingCard suit value public PlayingCard DealCardFromPack Suit suit Suit randomCardSelector Next NumSuit while IsSuitEmpty suit suit Suit randomCardSelector Next NumSuit Value value Value randomCardSelector Next CardsPerSuit while IsCardAlreadyDealt suit value value Value randomCardSelector Next CardsPerSuit PlayingCard card cardPack int suit int value this cardPack int suit int value null return card private bool IsSuitEmpty Suit suit throw new NotImplementedException bool result true for Value value Value Two value HandSize throw new ArgumentException too many cards this cards this playingCardCount cardDealt this playingCardCount public partial class MainWindow Window public const int NumOfHand 4 Pack pack null private Hand hands new Hand NumOfHand new Hand new Hand new Hand new Hand public MainWindow InitializeComponent Visual C Net A 第 13 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 hands new Hand NumOfHand private void button1 Click object sender RoutedEventArgs e try pack new Pack for int i 0 i NumOfHand i hands i new Hand for int j 0 j Hand HandSize j PlayingCard card pack DealCardFromPack hands i AddCardToHand card textBox1 Text hands 0 ToString textBox2 Text hands 1 ToString textBox3 Text hands 2 ToString textBox4 Text hands 3 ToString catch Exception ex MessageBox Show ex Message 6 请写一个程序 能读出文本文件内容 运行结果如下图如示 注 只写出 读文件 Button 按钮的方法即可 Visual C Net A 第 14 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 private void btnRead Click object sender RoutedEventArgs e OpenFileDialog openFileDiglog new OpenFileDialog openFileDiglog ShowDialog string filePath openFileDiglog FileName FileInfo fileInfo new FileInfo filePath string fileName fileInfo FullName this textBox1 Text fileName using TextReader reader new StreamReader fileName string line while line reader ReadLine null this textBox2 Text line n r 7 请用属性写一个员工添加程序 运行结果如下图所示 Visual C Net A 第 15 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 class Employee public static int currentCount public Employee currentCount public string Name get set public string Gender get set public int Age get set public double Salary get set private void btnAdd Click object sender RoutedEventArgs e Employee em new Employee try em Name this txtName Text em Gender this txtGender Text em Age Convert ToInt32 this txtAge Text em Salary Convert ToDouble this txtSalary Text catch Exception ex Visual C Net A 第 16 页 共 18 页 命题教师 陈长喜 装订线右侧答题区内不得留有姓名 学号等个人信息 否则本卷作废 this label6 Content ex Message this txtContent Text n em

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论