[计算机软件及应用]高级程序设计C第八章ppt课件.ppt
《[计算机软件及应用]高级程序设计C第八章ppt课件.ppt》由会员分享,可在线阅读,更多相关《[计算机软件及应用]高级程序设计C第八章ppt课件.ppt(40页珍藏版)》请在三一办公上搜索。
1、2023/1/3,1,高级程序设计,授课教师:祁长兴,C#,第八章:常用类,2023/1/3,2,常用类,2023/1/3,3,Math,静态字段PIE静态方法整数运算初等函数三角函数,Abs():求绝对值Ceiling()求大于等于指定数值的最小整数Floor()求小于或等于指定数值的最大整数Round()对数值进行四舍五入,Exp():求e的指数幂Pow()指数函数Log()对数函数Lg10()求以10为底的对数Sqrt()求平方根,Sin():求正弦函数Cos()求余弦函数Tan()求正切函数。,2023/1/3,4,static void Main(string args)double
2、 a=-1.2;int k=-1,d;double b,c;int i;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.
3、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();,2023/
4、1/3,5,Math,DemoP8-1,2023/1/3,6,string,构造函数与赋值 1。直接赋值:string s1=“software”2。构造函数赋值:string(char,int)string(char)string(char,int,int),2023/1/3,7,static void Main(string args)string s1=helloworld!;Console.WriteLine(s1=0,s1);string s2=new string(a,5);Console.WriteLine(s2=0,s2);char s3=new charm,i,c,r,o,s
5、,o,f,t;string s4=new string(s3);string s5=new string(s3,1,4);Console.WriteLine(s3=0,s3);Console.WriteLine(s4=0,s4);Console.WriteLine(s5=0,s5);Console.ReadLine();,2023/1/3,8,String,获取字符string char:索引函数string char:char ToChayArray()char ToChayArray(int int)/起始位置,复制的长度 CopyTo(int,char,int,int)/起始位置,目标数
6、组,指定数组起始位置,复制的长度,2023/1/3,9,static void Main(string args)string s1=Microsoft!;char chs1=s1.ToCharArray();char chs2=s1.ToCharArray(5,4);Console.WriteLine(new string(chs1);Console.WriteLine(new string(chs2);char chs=new char20;Microsoft.CopyTo(0,chs,0,9);Windows2003.CopyTo(0,chs,10,7);Console.WriteLin
7、e(new string(chs);Console.ReadLine();,2023/1/3,10,字符查找,int IndexOf(char)int IndexOf(char,int)int IndexOf(char,int,int)int LastIndexOf(char,int,int)int IndexOfAny(char),static void Main(string args)string s1=沈阳师范大学软件学院;int pos=s1.IndexOf(软);Console.WriteLine(pos=0,pos);Console.ReadLine();,2023/1/3,11
8、,public class SearchCharSample static void Main()bool bFail=true;string sName;char illChars=,#,$,%,2023/1/3,12,练习,输入一个字符串,求其中字符e出现的次数,2023/1/3,13,using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args
9、)/string s1=miscrosoft is a big company and it is super enterprise.I study from it and want to enter;s1=Console.ReadLine();int i=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();,2023/1/3,14,字符串填充与修剪,string PadLeft(int)string PadLeft(int cha
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机软件及应用 计算机软件 应用 高级 程序设计 第八 ppt 课件

链接地址:https://www.31ppt.com/p-2047747.html