noip复习手册

上传人:xzh****18 文档编号:44621833 上传时间:2018-06-14 格式:PDF 页数:53 大小:1.58MB
返回 下载 相关 举报
noip复习手册_第1页
第1页 / 共53页
noip复习手册_第2页
第2页 / 共53页
noip复习手册_第3页
第3页 / 共53页
noip复习手册_第4页
第4页 / 共53页
noip复习手册_第5页
第5页 / 共53页
点击查看更多>>
资源描述

《noip复习手册》由会员分享,可在线阅读,更多相关《noip复习手册(53页珍藏版)》请在金锄头文库上搜索。

1、NOIP 复习手册 崔晨 莒县一中第 1 页一、Pascal语言基础知识 1.基本数据类型 1.基本数据类型 Type Type Range Range Size in bytes Size in bytes 整型 byte 0.255 1 shortint -128 . 127 1 word 0 . 65535 2 integer -32768 . 32767 2 longint -231.231-1 4 longword 0.232-1 4 int64 -263.263-1 8 qword 0.264-1 8 实型 real 2.9E-39 . 1.7E38 6 single 1.5E-4

2、5 . 3.4E38 4 double 5.0E-324 . 1.7E308 8 comp -263+1.263-1 8 extended 3.4E-4932 . 1.1E4932 10 2.标准过程与函数 2.标准过程与函数 函数 函数 功能 功能 自变量类型 自变量类型 结果类型 结果类型 说明 说明 算术函数 abs(x) 绝对值 整型/实型 同自变量 求 x 的绝对值 sqr(x) 平方 整型/实型 同自变量 求 x 的平方 sqrt(x) 平方根 非负整型/非负实型 非负实数 求 x 的算数平方根 exp(x) 指数 整型/实型 实型 ex ln(x) 自然对数 整型/实型 实型 求

3、 x 的自然对数 转换函数 trunc(x) 截尾 实型 整型 取 x 的整数部分 round(x) 舍入 实型 整型 对 x 的十分位进行四 舍五入 ord(x) 序号 整型/字符型/布尔型整型 求 x 对应的序号 chr(x) 字符 整型 字符型 求序号 x 对应的字符顺序函数 pred(x) 前驱 整型/字符型/布尔型整型/字符型/布尔型 求 x 的前驱 succ(x) 后继 整型/字符型/布尔型整型/字符型/布尔型 求 x 的后继 逻辑判断函数 odd(x) 奇函数 整型 布尔型 判断 x 是否为奇数 NOIP 复习手册 崔晨 莒县一中第 2 页3.字符串的常用操作 3.字符串的常用操

4、作 操作 操作 类型 类型 作用 作用 返回值 返回值 例子 例子 length(s) 函数 求字符串 s 的长度 整型 s:=123456789; l:=length(s);l 的值为 9 copy(s,w,k) 函数 复制 s 中从 w 开始的 k 位字符串 s:=123456789; s1:=copy(s,3,5);s1 的值是34567 val(s,k,code) 过程 将字符串 s 转为数值,存 在 k 中; code 是错误代码无 var s:string;k,code:integer; s:=1234; val(s,k,code); write(k);k=1234 str(i,s

5、) 过程 将数值 i 转为字符串 s 无 i:=1234; str(i,s); write(s);s=1234 Delete(s,w,k) 过程 在 s 中删除从第 w 位开始 的 k 个字符 无 s := Honest Abe Lincoln; Delete(s,8,4); Writeln(s); Honest Lincoln Insert(s1,S,w) 过程 将 s1 插到 s 中第 w 位 无 S := Honest Lincoln; Insert(Abe , S, 8); Honest Abe Lincoln Pos(c,S) 函数 求字符 c 在 s 中的位置 整型 S := 12

6、3.5; i :=Pos( , S);i 的值为 1 + 运算 符 将两个字符串连接起来 无 s1:=1234; s2:=5678; s:=s1+s2;12345678 6.Pascal 常见错误含义常见错误含义 错误代码 错误代码 含义 含义 1 无效 DoS 功能号 2 文件末找到 102 文件变量末赋值 103 文件未打开 104 文件未用输入方式打开 105 文件末用输出方式打开 106 无效数字格式 200 被零除 201 范围检查错 202 堆栈溢出错 203 堆溢出错 204 无效指针操作 205 浮点上溢出 206 浮点下溢出 207 无效浮点运算 213 集合下标越界 214

7、 集合溢出 215 算术上溢错误 4.记录类型 4.记录类型 typetype 类型标识符= =recordrecord 字段名1:类型1; 字段名2:类型2; . 字段名n:类型n; endend; ; 5.文件类型 5.文件类型 assign(input,filename.in); reset(input); assign(output,filename.out); rewrite(output); close(input); close(output); NOIP 复习手册 崔晨 莒县一中第 3 页7.Math 库实用汇总 7.Math 库实用汇总 程序开头用 uses Math;来加载

8、 Math 库 函数名称 函数名称 原型 原型 功能 功能 ceil function ceil(x:float):Integer 返回比参数大的最小整数 floor function floor(x:float):Integer 返回比参数小的最大整数 power function power(base:float;exponent:float):float 返回 base 的 exponent 次方 intpower function intpower(base:float;const exponent:Integer):float 返回 base 的 exponent 次方 ldexp

9、function ldexp(x:float;const p:Integer):float 返回 2 的 p 次方乘以 x log10 function log10(x:float):float 返回 x 的常用对数 log2 function log2(x:float):float 返回 x 以 2 为底的对数 logn function logn(n:float;x:float):float 返回 x 以 n 为底的对数 Max function Max(a:Integer;b:Integer):Integer function Max(a:Int64;b:Int64):Int64 fun

10、ction Max(a:Extended;b:Extended):Extended 返回 a 与 b 中较大的一个 Min function Min(a:Integer;b:Integer):Integer function Min(a:Int64;b:Int64):Int64 function Min(a:Extended;b:Extended):Extended 返回 a 与 b 中较小的一个 arcsin function arcsin(x:float):float 返回 x 的反正弦值(弧度制) arccos function arccos(x:float):float 返回 x 的反

11、余弦值(弧度制) tan function tan(x:float):float 返回 x 的正切值(弧度制) cotan function cotan(x:float):float 返回 x 的余切值(弧度制) MaxValue function maxvalue(const data:Array of float):float function maxvalue(const data:Array of Integer):Integer function maxvalue(const data:PFloat;const N:Integer):float function maxvalue(c

12、onst data:PInteger;const N:Integer):Integer返回数组中的最大值 MinValue function minvalue(const data:Array of float):float function minvalue(const data:Array of Integer):Integer function minvalue(const data:PFloat;const N:Integer):float function MinValue(const Data:PInteger;const N:Integer):Integer返回数组中的最小值 s

13、um function sum(const data:Array of float):float function sum(const data:PFloat;const N:LongInt):float 求数组中所有数之和 * operator *(float,float):float(bas:float;expo:float):float operator *(Int64,Int64):Int64(bas:Int64;expo:Int64):Int64 同等于 Power,乘方的操作符 NOIP 复习手册 崔晨 莒县一中第 4 页二、常用算法和策略 数论算法 1.最大公因数最大公因数 fu

14、nction gcd(a,b:longint):longint; begin if b=0 then exit(a) else exit(gcd(b,a mod b); end; 2.最小公倍数 2.最小公倍数 function lcm(a,b:longint):longint; begin lcm:=a div gcd(a,b)*b;/notice:要先除后乘,避免溢出 end; 3.快速幂算法pow 3.快速幂算法pow function pow(x,n:longint):longint;overload; begin if n=0 then exit(1); pow:=pow(x,n div 2); pow:=pow*pow; if (n and 1)=1 then pow:=pow*x; end; 4.快速幂算法pow(mod p) 4.快速幂算法pow(

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 理论文章

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号