




已阅读5页,还剩25页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
测试题测试题 1 C 中有哪几种注释符 单行注释 多行注释 文档注释 是针对函数方法注释的 2 对学员的结业考试成绩评测 要求在控制台中提示用户输入学员考试成绩 写一个方法 根据用户输入 的成绩 返回一个等级 90分以上A级 80 90分B级 70 80分C级 60 70分B级 60分以下C级 Console WriteLine 请 输 入 成 绩 o int score int Parse Console ReadLine if score 90 Console WriteLine A级 else if score 80 Console WriteLine B级 else if score 70 Console WriteLine C级 else if score 60 Console WriteLine D级 else Console WriteLine 不 及 格 Console ReadKey 如图所示 3 在控制台中提示用户输入一个年龄 如果用户输入的年龄大于 18 岁 则提示用户 可以查看 如果 小于10岁 则提示用户 不可以查看 如果在10岁到18岁之间 则提示用户 是否继续查看 yes no 如果用户输入 yes 则提示可以查看 否则提示不可以查看 Console WriteLine 请 输 入 你 的 年 龄 o int age int Parse Console ReadLine if age 18 Console WriteLine 可 以 查 看 else if age 0 Console WriteLine 请 输 入 一 个 月 份 Y o int m int Parse Console ReadLine if m 0 break case 2 if y 400 0 y 100 0 else Console WriteLine 28 break case 4 case 6 case 9 case 11 Console WriteLine 30 break else Console WriteLine 请 输 入 1 12的 整 数 y else Console WriteLine 您 输 入 有 D误 请 输 入 一 个 正y 整 数 y i while i 3 如图所示 5 在控制台中提示 这道题我给你讲一遍 你会了吗 接收用户回答 如果用户回答 我会了 则提示放学 并退出程序 如果用户回答 不会 则继续提问 这道题我再给你讲一遍 你会了么 可以退出程序条件 1 直到学生回答 会了 则可以退出程序 2 直到老师讲了10遍 不管会不会都放学 两个条件满足一个即可 for int i 0 i 999 n 100 Console WriteLine 输 入 有 D误 else int a int n 100 int b int n 100 10 int c int n 10 if a a a b b b c c c n Console WriteLine n 是 水 仙 花 数 y else Console WriteLine n 不 是 水 仙 花 数 y catch Exception ex Console WriteLine ex Message 7 在控制台中不断要求用户输入一个数字 假定用户输入的都是正整数 当输入end的时候 显示刚才输 入的数字中的最大值 int max 0 while true Console WriteLine 请 输 入 一 个 数 y字 o string s Console ReadLine try int n int Parse s if max n max n catch if s end Console WriteLine 刚 才 您 输 入 的 数 y字 中D 最 大 值 为a o max break else return Console ReadKey 如图所示 8 向控制台中打印1 100以内所有的质数 质数 只能被1和自身整除的数字 for int i 1 i 101 i int n 0 for int j 1 j i j if i j 0 n if n 2 Console WriteLine i Console ReadKey 第二部分第二部分字符串的操作测试字符串的操作测试 9 有这样的一个数组 里面存储的都是人的姓名 老杨 老邹 老苏 老虎 老牛 老 蒋 老王 老马 写一个程序 将这个数组的元素分割成一个字符串 老杨 老苏 老邹 老虎 老牛 老将 老王 老马 注意 最后一个人的名字后面没有竖线 并将最终结果输出到控制台 10 有如下字符串数组 非常 高兴 来到 传智播客学习 写一段程序 将数组中 的每个元素的位置进行翻转 最终变成 传智播客学习 来到 高兴 非常 并将数组中 的元素输出到控制台 string str 非 常 高 兴 来 到 传 智 播 客 学 习 大 家 好 for int i 0 i str Length 2 i string t str i str i str str Length 1 i str str Length 1 i t for int i 0 i str Length i Console WriteLine str i Console ReadKey 11 从如下email中提取出用户名和域名 abc 并打印到控制台 最终结果 string s abc string name s Substring 0 s IndexOf int a s IndexOf int b s IndexOf string yuming s Substring a 1 b Console WriteLine 用户名为 name 域名为 yuming Console ReadKey 如图所示 12 在控制台中提示用户输入一句英文 找出这句英文中所有e出现的位置 例如 在控制台中输入 hellochinese 则输出 如图所示 string s hello chinese int n 0 for int i 0 i s Length i if s i e n Console WriteLine 第 n 次 出 现 e 的 位 置 是 o i 1 Console ReadKey 13 有如下字符串数组 诸葛亮 鸟叔 卡卡西 卡哇伊 将每个元素的后面都加上竖线 转成字符串如 诸葛亮 鸟叔 卡卡西 卡哇伊 最后一个元素的后面没有竖线 然后再将字符串中的竖线 切割掉 将最终结果打印到控制台中 string s 诸 葛e亮 鸟 叔 卡 卡 西 卡 哇 伊 string str for int i 0 i 0 s i s i str s i Console WriteLine str string newStr str Replace Console WriteLine newStr Console ReadKey 14 请将 WelcomeToChina 这个字符串每个字符出现的次数打印到控制台中 string s Welcome To China Dictionary dict new Dictionary char c s ToCharArray int n new int s Length for int i 0 i c Length i if dict ContainsKey c i dict Add c i 1 else dict c i foreach KeyValuePair item in dict Console WriteLine 出 现 0 的 次 数 y为a o item Value item Key 15 有如下字符串 患者 大夫 我咳嗽得很重 大夫 你多大年记 患者 七十五岁 大夫 二十岁咳嗽吗 患者 不咳嗽 还要等到什么时咳嗽 需求 请统计出该字符中 咳嗽 二字的出现次数 以及每次 咳嗽 出现的索引位置 扩展 统计出每个字符的出现次数 结果输出到控制台 string s 患 者 o 大 夫 我 咳 嗽 得 很 重 大 夫 o 你 多 大 年 记 患 者 o 七 十 五 岁 大 夫 o 二t 十 岁 咳 嗽 吗e 患 者 o 不 咳 嗽 还1要 a等 到 什 2么 时 咳 嗽 string keyword 咳 嗽 int count 0 int index 0 while index s IndexOf keyword index 1 找 不 到 返 回 1 从 index的 位 置 开a始 查 找 count Console WriteLine 索 引 y是 0 出 现 第 1 次 index count index index keyword Length Dictionary dict new Dictionary char ch s ToCharArray for int i 0 i ch Length i if dict ContainsKey ch i dict Add ch i 1 else dict ch i foreach var item in dict Console WriteLine 出 现 0 的 次 数 y是 1 item Key item Value Console ReadKey 16 将字符串 helloworld 你好世界 的两端的空格去掉 并且将其中的所有其他空格都替换成一个空格 最终输出结果为 helloworld 你好世界 string s helloworld 你 好 世 界 s s Trim string str s Split new char StringSplitOptions RemoveEmptyEntries string newStr string Join str Console WriteLine newStr newStr Regex Replace s s 正y则 表 达 式 Console WriteLine newStr 第三部分 方法测试第三部分 方法测试 17 写一个方法 用来读取用户在控制台输入的数字 如果是数字 则打印这个数字的二倍 如果不是数 字 则提示用户重新输入 直到是数字为止 static void Main string args Console WriteLine 请 输 入 一 个 数 y字 我 们 将 打 印 这a个 数 y字 的 2倍 do string s Console ReadLine CheckNumber s while 1 1 Console ReadKey public static void CheckNumber string s try int n int Parse s Console WriteLine 您 输 入 的 数 y字 的 2倍 是 n 2 Console WriteLine 程 序 退 出 catch Console WriteLine 请 重 新 输 入 数 y字 如图所示 18 在控制台中提示用户输入yes或者no 写一个方法判断用户的输入 要求只允许用户输入yes或者no 否则就一直提示用户重新输入 如图所示 static void Main string args Console WriteLine 请 输 入 yes或 者 no o do string s Console ReadLine Show s while 1 1 Console ReadKey static void Show string s if s yes else Console WriteLine 程 序 退 出 Environment Exit 0 19 写一个方法 使用这个方法可以求得一个整数类型数组的最大值 最小值 总和 平均值 使用out 参数返回多个值 static void Main string args int s new int 2 4 6 7 8 0 int max min sum avg GetValue s out max out min out sum out avg Console WriteLine 数 y组 s 的 最 大 值 o max n最 小 值 为a o min n总 和 为a o sum n平 均 值 为a o avg Console ReadKey static void GetValue int s out int max out int min out int sum out int avg sum s 0 max s 0 min s 0 for int i 1 i s i 1 min s i 1 if s i s i 1 max s i 1 sum sum s i avg sum s Length 20 在控制台中提示用户输入用户名和密码 写一个方法判断用户是否登录成功 如果登录成功 返回true 并且返回 登录成功 登录失败返回false 并且返回 登录失败 提示 使用out参数 static void Main string args Console WriteLine 请 输 入 用 户 名 o string name Console ReadLine Console WriteLine 请 输 入 密 码 o string pwd Console ReadLine bool b Validate name pwd out b Console WriteLine 返 回 值 b b Console ReadKey static void Validate string name string pwd out bool b if name admin b true else Console WriteLine 登 录 失 败 b false 21 写一个方法 来交换两个int类型的变量的值 提示 使用ref参数 static void Main string args 写 一 个 方 法 来 交 换 两 个 int类 型 的 变 量 的 值 提 示 o使 1用 ref参 数 y Console WriteLine 输 入 a o int a int Parse Console ReadLine Console WriteLine 输 入 b int b int Parse Console ReadLine Exchange ref a ref b Console WriteLine a的 值 是 o 0 b的 值 o 1 a b Console ReadKey static void Exchange ref int a ref int b int t a a b b t 22 写一个方法 来实现对一个整数类型数组进行升序排列 要求使用冒泡排序 static void Main string args int s 3 1 4 7 2 5 6 Sort s Console ReadKey static void Sort int s for int i 0 i s Length i for int j i 1 j s j int t s i s i s j s j t for int i 0 i s Length i Console Write s i 23 有一个字符串数组 马龙 迈克尔乔丹 雷吉米勒 蒂姆邓肯 科比布莱恩特 写一个方法来计算这个数组中最长的字符串 并输出到控制台 static void Main string args string s 马 龙 迈 克 尔 乔 丹 雷 吉a米 勒 蒂 姆 邓 肯 科 比 布 莱 3恩 特 GetLong s Console ReadKey static void GetLong string s string mostLong s 0 for int i 0 i s Length i if mostLong Length s i Length mostLong s i Console WriteLine mostLong 24 有一个字符串 HelloCSharp 写一个方法 将此字符串 翻转为 SharpCHello 并打印到控制台 static void Main string args string s Hello C Sharp FanZhuan s Console ReadKey static void FanZhuan string s string str s Split for int i 0 i str Length 2 i string t str i str i str str Length i 1 str str Length 1 i t s string Join str Console WriteLine s 第三部分第三部分面向对象面向对象 25 请简述你对 c 中抽象类的理解 1 当一个类不与具体的事物联系 而只表达一种抽象的概念 仅仅作为其派生类的一个基类 就是抽象类 2 既可以提供抽象方法 也可以提供非抽象方法 3 抽象类不能实例化 必须通过继承有派生类实现其抽象方法 所以不能用 new 关键字 也不能密封 4 如果派生类没有实现所有的抽象方法 则派生类页必须声明为抽象类 5 实现抽象方法使用 override 关键字来实现 26 请简述你对 c 中接口的理解 1 接口是一种程序的协定 2 接口包含了一组虚方法的抽象模型 其中每一种方法都有其名称 参数和返回值 3 接口不能包含任何实现 CLR 接口允许借口可以包含事件 属性 索引器 静态方法 静态字段 静态 构造函数以及常数 4 一个类可以实现多个接口 当一个类继承某个接口时 它不仅要实现该接口定义的所有方法 还要实现 该接口从其它接口中继承的所有方法 27 使用抽象类来实现 计算圆形和矩形的面积和周长 要求 写一个 Shape 类作为圆形和矩形的父 类 提供两个抽象方法 分别用来计算周长和面积 子类圆形和矩形分别在自己的类中重写父类的抽象方 法 Circle cs Circle cs class Circle Shape public int R get set const double pi 3 14 public override double GetGirth return 2 pi R public override double GetArea return pi R R 主程序 class Program 使 1用 抽 象 类 来 实 现 计 算 圆2形 和 矩 形 的 面 积y和 周 长 要 a求 o 写 一 个 Shape 类 作 为a圆2形 和 矩 形 的 父 类 提 供 两 个 抽 象 方 法 分 别 e用 来 计 算 周 长 和 面 积 y 子 类 圆2形 和 矩 形 分 别 e在 自 己o的 类 中D重 写 父 类 的 抽 象 方 法 static void Main string args Circle c new Circle c R 3 Console WriteLine 圆2形 c的 周 长 是 0 面 积y是 1 c GetGirth c GetArea Rectangle rect new Rectangle rect H 2 rect L 5 Console WriteLine 矩 形 rect的 周 长 是 0 面 积y是 1 rect GetGirth rect GetArea Console ReadKey RectangleRectangle cs cs class Rectangle Shape public int L get set public int H get set public override double GetGirth return 2 L H public override double GetArea return L H shape cs shape cs public abstract class Shape public abstract double GetGirth public abstract double GetArea 28 超市现在提供 3 种打折方式 1 打 95 折 2 打 8 折 3 买 500 送 100 要求 写一个打折的抽象父类 并且在父类中提供一个打折的抽象方法 子类继承父类后 重写父类总的打折抽象方法 在控制台中提示用户请选择一个打折方式 根据用户的输 入 使用简单工厂设计模式获得一个打折的对象 并计算打折后的价钱 价钱可以自己定义 第四部分 第四部分 winformwinform测试测试 29 使用多线程实现摇奖机程序 创建winform应用程序 要求 放入3个label控件 再放入一个button控件 按钮默认显示文本为 开始 当点击按钮的时候 按钮的文本变为 停止 并且label中的文本从0 9随机转动 单再次点击按钮的时候 按钮的文本变为 开始 并且label中的文本停止转动 第五部分 第五部分 HTML CSSHTML CSS 30 请使用HTML实现下面的页面 并在左侧
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年电子器件制造行业研究报告及未来行业发展趋势预测
- 湿地水源保护与水土保持方案
- 2025年宗教祭祀殡葬行业研究报告及未来行业发展趋势预测
- 2025年孤残儿童收养和庇护服务行业研究报告及未来行业发展趋势预测
- 幼儿教师学习3-6岁指南及纲要总结
- 2025年社会人文科学研究行业研究报告及未来行业发展趋势预测
- 2025低压电工证必刷题库及答案
- 2025年餐饮娱乐加盟行业研究报告及未来行业发展趋势预测
- 2025年搪瓷日用品及其他搪瓷制品制造行业研究报告及未来行业发展趋势预测
- 2025年多肉植物行业研究报告及未来行业发展趋势预测
- 2025年公共卫生基本知识题库及答案
- 医院检验科微生物进修汇报
- 主播跟运营合作合同协议
- 2025年云南国企招聘考试历年参考题库含答案详解(5卷)
- 血透室设备维护与操作规范
- 导尿管相关性尿路感染
- 2025至2030高校后勤行业发展趋势分析与未来投资战略咨询研究报告
- 2025年幼儿园膳食工作计划
- 贵州省黔东南苗族侗族自治州2024-2025学年七年级下学期7月期末考试地理试卷含答案
- 【课件】重生之我是学霸 2025-2026学年高二上英语开学第一课
- 锦绣中国课件教学
评论
0/150
提交评论