




已阅读5页,还剩35页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2020 1 18 1 高级程序设计 授课教师 祁长兴 C 第八章 常用类 2020 1 18 2 常用类 2020 1 18 3 Math 静态字段PIE静态方法整数运算初等函数三角函数 Abs 求绝对值Ceiling 求大于等于指定数值的最小整数Floor 求小于或等于指定数值的最大整数Round 对数值进行四舍五入 Exp 求e的指数幂Pow 指数函数Log 对数函数Lg10 求以10为底的对数Sqrt 求平方根 Sin 求正弦函数Cos 求余弦函数Tan 求正切函数 2020 1 18 4 staticvoidMain string args doublea 1 2 intk 1 d doubleb c inti b Math Abs a Console WriteLine Abs a 0 b d Math Abs k Console WriteLine Abs k 0 d c Math Ceiling 1 2 Console WriteLine Ceiling 1 2 0 c c Math Floor 1 2 Console WriteLine Floor 1 2 0 c c Math Round 1 5 Console WriteLine Round 1 5 0 c c Math Round 1 2 Console WriteLine Round 1 2 0 c b Math Exp 2 1 Console WriteLine Exp 2 1 0 b b Math Pow 2 3 Console WriteLine Pow 2 3 0 b b Math Log 10 Console WriteLine Log 10 0 b b Math Log10 10 Console WriteLine Log10 10 0 b b Math Sqrt 9 Console WriteLine Sqrt 9 0 b Console ReadLine 2020 1 18 5 Math DemoP8 1 2020 1 18 6 string 构造函数与赋值1 直接赋值 strings1 software 2 构造函数赋值 string char int string char string char int int 2020 1 18 7 staticvoidMain string args strings1 helloworld Console WriteLine s1 0 s1 strings2 newstring a 5 Console WriteLine s2 0 s2 char s3 newchar m i c r o s o f t strings4 newstring s3 strings5 newstring s3 1 4 Console WriteLine s3 0 s3 Console WriteLine s4 0 s4 Console WriteLine s5 0 s5 Console ReadLine 2020 1 18 8 String 获取字符string char 索引函数string char char ToChayArray char ToChayArray intint 起始位置 复制的长度CopyTo int char int int 起始位置 目标数组 指定数组起始位置 复制的长度 2020 1 18 9 staticvoidMain string args strings1 Microsoft char chs1 s1 ToCharArray char chs2 s1 ToCharArray 5 4 Console WriteLine newstring chs1 Console WriteLine newstring chs2 char chs newchar 20 Microsoft CopyTo 0 chs 0 9 Windows2003 CopyTo 0 chs 10 7 Console WriteLine newstring chs Console ReadLine 2020 1 18 10 字符查找 intIndexOf char intIndexOf char int intIndexOf char int int intLastIndexOf char int int intIndexOfAny char staticvoidMain string args strings1 沈阳师范大学软件学院 intpos s1 IndexOf 软 Console WriteLine pos 0 pos Console ReadLine 2020 1 18 11 publicclassSearchCharSample staticvoidMain boolbFail true stringsName char illChars 2020 1 18 12 练习 输入一个字符串 求其中字符 e 出现的次数 2020 1 18 13 usingSystem usingSystem Collections Generic usingSystem Linq usingSystem Text namespaceConsoleApplication1 classProgram staticvoidMain string args strings1 miscrosoftisabigcompanyanditissuperenterprise Istudyfromitandwanttoenter s1 Console ReadLine inti 0 j 0 pos 0 while pos 0 pos s1 IndexOf e j if pos 0 i j pos 1 Console WriteLine i 0 i Console ReadLine 2020 1 18 14 字符串填充与修剪 stringPadLeft int stringPadLeft intchar stringTrim stringTrim char TrimStart TrimEnd 2020 1 18 15 staticvoidMain string args strings1 Microsoft s2 s3 s4 s2 s1 PadLeft 12 s3 s2 PadRight 14 s4 s3 PadLeft 16 s4 s4 PadRight 18 Console WriteLine 0 s4 Console ReadLine 2020 1 18 16 String 获取子串SubString查找子串IndexOf LastIndexOfStartsWith EndWith插入 删除子串Insert Remove替换子串Replace 2020 1 18 17 练习 输入一个字符串 去掉其中子串 err 2020 1 18 18 staticvoidMain string args strings1 Microsoftisareabigcompanyandtheleaderinitisaresuperman s1 Console ReadLine intpos 0 while pos 0 pos s1 IndexOf are if pos 0 s1 s1 Substring 0 pos s1 Substring pos are Length Console WriteLine 0 s1 Console ReadLine 问题是 Microsoftisareabigcompanyandtheleaderinitisaareresuperman 2020 1 18 19 staticvoidMain string args strings1 Microsoftisareabigcompanyandtheleaderinitisaareresuperman s2 s2 intpos 0 while pos 0 pos s1 IndexOf are if pos 0 s2 s2 s1 Substring 0 pos s1 s1 Substring pos are Length s2 s1 Console WriteLine 0 s2 Console ReadLine 2020 1 18 20 staticvoidMain string args strings1 Microsoftisareabigcompanyandtheleaderinitisaareresuperman s2 s2 s1 Replace are Console WriteLine 0 s2 Console ReadLine 2020 1 18 21 Remove Insert 2020 1 18 22 String 格式化字符串Format解析字符串Parse TryParseDemo 2020 1 18 23 StringBuilder 构造函数性能优化Demo 2020 1 18 24 常用数据结构类 DateTime 日期 时间你会如何设计这个类 ArrayList 链表你会如何设计这个类 Demo 2020 1 18 25 String 编写程序 输入一个字符串 求串中包含字符串 am 的个数 2020 1 18 26 staticvoidMain string args strings1 iamamiddleschoolstudentndiamaboy iamateacher intj 0 k 0 i 0 while i 0 i s1 IndexOf am k Console WriteLine i 0 i if i 0 j k i am Length Console WriteLine s1 0 j Console ReadLine 2020 1 18 27 String 判断输入的字符串是否为有效身份证号码 18位 第7位开始 连续8个数字为日期即可 2020 1 18 28 classProgram staticvoidMain string args strings1 Console ReadLine if s1 Length 18 Console WriteLine 无T效 的 身 份 证 号 码 else strings2 s1 Substring 6 8 s2 s1 Substring 6 4 s1 Substring 10 2 s1 Substring 12 2 try DateTimed1 DateTime Parse s2 Console WriteLine 有瓺效 的 身 份 证 号 码 catch Exception Console WriteLine 无T效 的 身 份 证 号 码 finally Console ReadLine 2020 1 18 29 常用类 Windows窗体和控件 2020 1 18 30 Windows窗体和控件 ColorSize PointSizeF PointFDemo 2020 1 18 31 Windows窗体和控件 Form构造函数属性方法事件Demo 2020 1 18 32 Windows窗体和控件 Control属性方法事件 2020 1 18 33 Windows窗体和控件 2020 1 18 34 Windows窗体和控件 模态ShowDialog非模态Show常用事件LoadFormClosingFormClosed 2020 1 18 35 Windows窗体和控件 privatevoidForm1 FormClosing objectsender FormClosingEventArgse MessageBox Show Form1 FormClosing privatevoidForm1 FormClosed objectsender FormClosedEventArgse MessageBox Show Form1 FormClosed privatevoidForm1 Activated objectsender EventArgse MessageBox Show Form1 Activated privatevoidForm1 Deactivate objectsender EventArgse MessageBox Show Form1 Deactivate privatevoidForm1 SizeChanged objectsender EventArgse MessageBox Show Form1 SizeChanged privatevoidForm1 LocationC
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 医疗行业2025年人才流动趋势及培养策略研究报告
- 中职学院学籍管理办法
- 住宅装修管理办法细则
- 人员内部流动管理办法
- 企业电机维修管理办法
- 乡镇工会会员管理办法
- 企业融合销售管理办法
- 临时用地补偿管理办法
- 保险培训管理办法试行
- 临汾供热收费管理办法
- 2025年职业病防治宣传日知识竞赛参考试题库400题(含答案)
- 公司行政5s管理制度
- 家庭消毒知识课件
- 2024人教版七年级下册生物第三单元 植物的生活 单元测试卷(含答案)
- 市政道路地下综合管廊工程总承包项目施工进度计划及保证措施
- 2024-2025学年江苏省南通市高一(上)期末物理试卷(含答案)
- 2025年重庆出版集团招聘笔试参考题库含答案解析
- 施工现场重大危险源辨识及监控措施
- 新产品开发流程
- 介绍正畸课件教学课件
- 译林版(2024新版)英语七年级上册Units 1~2 综合测试卷(含答案)
评论
0/150
提交评论