




已阅读5页,还剩13页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
104说明:做完一个题目后,请将源程序和运行结果截图直接复制到题目的下面。运行结果截图请调节到合适的大小。源程序必须是文本,不能是截图。(界面截图的复制:Alt+PrtSc,粘帖:Ctrl+v)创建一个控制台项目,项目名称为“姓名_104”。项目存放在F盘之下。Part 1 一维数组1. 编程:把下面的数组中的正的偶数输出,并输出这些数的和以及数量。108, 101, 3, -9, -8, 10, -19, 10, 12, 8, -18, -4, 14, 11,28,46,-25,107, 82,74,95,113,-77,69,-28,37,36, 100,-92,88,102,68,-63,20,33,81using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) int x = 108, 101, 3, -9, -8, 10, -19, 10, 12, 8, -18, -4, 14, 11, 28, 46, -25, 107, 82, 74, 95, 113, -77, 69, -28, 37, 36, 100, -92, 88, 102, 68, -63, 20, 33, 81 ; int sum = 0, count = 0; Console.WriteLine(该数组中的正的偶数:); for (int i = 0; i 0) Console.WriteLine(xi); count+; sum = sum + xi; Console.WriteLine(和是: + sum); Console.WriteLine(数量是: + count); Console.ReadLine(); 2. 已知如下的变量:int a=10,b=25,c=40,d=80,e=30,f=13;将上面这些变量构建一个数组,然后用循环输出数组的元素。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) int a = 10, b = 25, c = 40, d = 80, e = 30, f = 13; int x = a, b, c, d, e, f ; for (int i = 0; i x.Length; i+) Console.WriteLine(xi); Console.ReadLine(); 3. 已知如下的变量:DateTime d1=DateTime.Now, d2=DateTime.Now.AddMonths(1), d3=new DateTime(2013,4,8);DateTime d4=new DateTime(2014,11,10), d5=DateTime.Now.AddDays(200);将上面这些变量构建一个数组,然后用循环输出数组中每个日期是星期几。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) DateTime d1 = DateTime.Now, d2 = DateTime.Now.AddMonths(1), d3 = new DateTime(2013, 4, 8); DateTime d4 = new DateTime(2014, 11, 10), d5 = DateTime.Now.AddDays(200); DateTime x = d1, d2, d3, d4, d5 ; for (int i = 0; i x.Length; i+) Console.WriteLine(int)xi.DayOfWeek); Console.ReadLine(); Part2 Split4. 下面是一段英文,请用SPLIT将其拆分为一个个单词存于数组中,将其中e或E开头的单词输出。Europes ills already have damaged some U.S. interests, from multinational companies to major exporters. Individual investors have many reasons for concern, as the enthusiasm from earlier debt agreements has given way to pessimism and stock market dives. If the U.S. economy takes such a turn into 2012, Europes financial troubles could wind up affecting the U.S. presidential election.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) string s1 = Europes ills already have damaged some U.S. interests, from multinational companies to major exporters. Individual investors have many reasons for concern, as the enthusiasm from earlier debt agreements has given way to pessimism and stock market dives. If the U.S. economy takes such a turn into 2012, Europes financial troubles could wind up affecting the U.S. presidential election.; string x = s1.Split( ); for (int i = 0; i x.Length; i+) if (xi.StartsWith(e) Console.WriteLine(xi); Console.ReadLine(); 5. 下面是一段英文,将其中的.和,和都替换为空格,再输出其中长度大于5的单词。Europes ills already have damaged some U.S. interests, from multinational companies to major exporters. Individual investors have many reasons for concern, as the enthusiasm from earlier debt agreements has given way to pessimism and stock market dives. If the U.S. economy takes such a turn into 2012, Europes financial troubles could wind up affecting the U.S. presidential election.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) string s1 = Europes ills already have damaged some U.S. interests, from multinational companies to major exporters. Individual investors have many reasons for concern, as the enthusiasm from earlier debt agreements has given way to pessimism and stock market dives. If the U.S. economy takes such a turn into 2012, Europes financial troubles could wind up affecting the U.S. presidential election.; string s2 = s1.Replace(., ); s2 = s2.Replace(, ); s2 = s2.Replace(, ); string x = s2.Split( ); for (int i = 0; i 5) Console.WriteLine(xi); Console.ReadLine(); Part3 二维数组6. 下面是10名学生的姓名与居住地,以二维数组的形式提供。柴旭东,浙江,陈飞,上海,陈斐,浙江,陈锋,福建,赵立伟,上海,朱孔磊,浙江,朱微珍,江苏,朱学婷,福建,蔡良若,上海,曹庆勋,广东输入一个省份,输出该省份的学生姓名。输入1:上海输入2:浙江using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) string, axx = new string, 柴旭东, 浙江 , 陈飞, 上海 , 陈斐, 浙江 , 陈锋, 福建 , 赵立伟, 上海 , 朱孔磊, 浙江 , 朱微珍, 江苏 , 朱学婷, 福建 , 蔡良若, 上海 , 曹庆勋, 广东 ; int i = 0; string n = Console.ReadLine(); for (i = 0; i 10; i+) if (axxi, 1 = n) Console.WriteLine(axxi, 0); Console.ReadLine(); 7. 修改下列网页标题和网址的格式,使之可以初始化存入一个二维数组。新浪|百度|腾讯|淘宝购物|163邮箱|城市学院|然后用循环列出所有的网页名称,再列出所有的网址。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) string, axx = new string, 新浪, , 百度, , 腾讯, , 淘宝购物, , 163邮箱, , 城市学院, ; int i = 0; for (i = 0; i 6; i+) Console.WriteLine(axxi, 0); for (i = 0; i 6; i+) Console.WriteLine(axxi, 1); Console.ReadLine(); Part4 枚举类型8. 模仿教程中的例子,定义一个枚举类型Direction表示方向,其值为东南西北,仿照教程用此类型定义两个变量并赋值(赋的值从枚举值中任选),最后输出变量的值。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program enum Direction 东, 南, 西, 北 ; static void Main(string args) Direction d1 = Direction.西; Direction d2 = Direction.南; Console.WriteLine(d1); Console.WriteLine(d2); Console.ReadLine(); 9. ConsoleColor是一种.NET提供的枚举类型,使用它定义2个变量并赋值(赋的值从枚举值中任选),最后输出这些变量的值;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) ConsoleColor a1 = ConsoleColor.Red; ConsoleColor a2 = ConsoleColor.Blue; Console.WriteLine(a1); Console.WriteLine(a2); Console.ReadLine(); 10. ConsoleColor是一种.NET提供的枚举类型,使用它定义一个数组,其元素分别代表红、黄、蓝、白、黑等颜色。使用循环输出数组中的所有元素。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) ConsoleColor x = new ConsoleColor ConsoleColor.Red, ConsoleColor.Blue, ConsoleColor.Yellow, ConsoleColor.Green, ConsoleColor.White ; for (int i = 0; i x.Length; i+) Console.WriteLine(xi); Console.ReadLine(); Part5 错误捕获11. 输入一个数,如果可以转换为整数,则输出其平方,否则输出“不是整数”(采用错误捕获的方法)输入1:887输入2:jfdeiusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) string n = Console.ReadLine(); int x = 0; try x = Convert.ToInt32(n); Console.WriteLine(x * x); catch (Exception e) Console.WriteLine(不是整数); Console.ReadLine(); Part6 综合题12. 编程:把下面的数组中的最大的数输出108, 101, 3, -9, -8, 10, -19, 10, 12, 8, -18, -4, 14, 11,28,46,25,107, 82,74,95,113,77,69,28,37,36, 100,92,88,102,68,63,20,33,81using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) int x = 108, 101, 3, -9, -8, 10, -19, 10, 12, 8, -18, -4, 14, 11, 28, 46, -25, 107, 82, 74, 95, 113, -77, 69, -28, 37, 36, 100, -92, 88, 102, 68, -63, 20, 33, 81 ; int max = 0; for (int i = 0; i max) max = xi; Console.WriteLine(max); Console.ReadLine(); 13. 编程:把下面的数组中的最长的字符串输出multinational, companies, to, major, exporters., Individual, investors, have, many, reasons, for, concernusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) string x = multinational, companies, to, major, exporters., Individual, investors, have, many, reasons, for, concern ; int max = 0, j = 0; for (int i = 0; i max) max = xi.Length; j = i; Console.WriteLine(xj); Console.ReadLine(); 14. 可选题:把下面的数组中的第一个负数之前的所有元素输出。如果找不到,输出“找不到”。(可参阅教程例子)108, 101, 3, -9, -8, 10, -19, 10, 12, 8, -18, -4, 14, 11,28,46,25,107, 82,74,95,113,77,69,28,37,36, 100,92,88,102,68,63,20,33,81using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) int x = 108, 101, 3, -9, -8, 10, -19, 10, 12, 8, -18, -4, 14, 11, 28, 46, -25, 107, 82, 74, 95, 113, -77, 69, -28, 37, 36, 100, -92, 88, 102, 68, -63, 20, 33, 81 ; int j = -1; for (int i = 0; i x.Length; i+) if (xi = 0) for (int i = 0; i j; i+) Console.WriteLine(xi); else Console.WriteLine(找不到); Console.ReadLine(); 15. 通过设置Console的背景色与前景色(即字体色),使得输出如下界面:(背景色:Console.BackgroundColor, 前景色:Console.ForegroundColor)using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 柯嘉文 class Program static void Main(string args) Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(我在学C#2014); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(我在学C#2014); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Red; Console.WriteLine(我在学C#2014); Console.ReadLine(); Part7 机动题16. 下面是一段英文,请用SPLIT将其拆分为一个个单词存于数组中,找出其中第一个含有t的单词,输出该单词之前的所有单词。Europes ills already have damaged some U.S. interests, from multinational companies to major exporters. Individual investors have many reasons for concern, as the enthusiasm from earlier debt agreements has given way to pessimism and stock market dives. If the U.S. economy takes such a turn into 2012, Europes financial troubles could wind up affecting
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 课题3 金属资源的利用和保护教学设计-2025-2026学年初中化学九年级全一册人教版(五四学制)
- 小小理财师教学设计-2025-2026学年小学综合实践活动五年级上册浙科技版
- 人教版四年级上册数学1-3单元测试卷6套(含答案)
- 2025年全国焊工操作证理论考试练习题库(含答案)
- 蒸馏、分馏、干馏的区别
- 物流运输实务(第三版)习题及答案 项目四 同步测试
- 蒸汽的力量课件
- 2025未签书面合同风险:以杭州、南京、成都为例
- 2025高考英语试题分类汇编:非谓语动词与交际用语含解析
- 消考数字类题目及答案
- 《国家电网公司电力安全工作规程(配电部分)》
- 金融学黄达ppt课件9.金融市场
- 第1章 数据与统计学-统计学
- GB/T 3758-2008卡套式管接头用锥密封焊接接管
- GB/T 2059-2000铜及铜合金带材
- GA/T 1105-2013信息安全技术终端接入控制产品安全技术要求
- 一中第一学期高一年级组工作计划
- 外科学课件:泌尿、男生殖系统外科检查
- 建设工程 施工档案数字化方案
- 轻钢结构施工专项方案
- 内科学:心律失常
评论
0/150
提交评论