C语言函数大全-l开头-完整版
C语言常用函数

C语言的常用库函数函数1。
absread()读磁盘绝对扇区函数原形:int absread(int drive,int num,int sectnum,void *buf)功能:从drive指定的驱动器磁盘上,sectnum指定的逻辑扇区号开始读取(通过DOS中断0x25读取)num 个(最多64K个)扇区的内容,储存于buf所指的缓冲区中。
参数:drive=0对应A盘,drive=1对应B盘。
返回值:0:成功;-1:失败。
头文件:dos.h函数2。
abswrite()写磁盘绝对扇区函数原形:int abswrite(int drive,int nsects,int lsect,void *buffer)drive=0(A驱动器)、1(B驱动器)、nsects=要写的扇区数(最多64K个);lsect=起始逻辑扇区号;buffer=要写入数据的内存起始地址。
功能:将指定内容写入(调用DOS中断0x26)磁盘上的指定扇区,即使写入的地方是磁盘的逻辑结构、文件、FAT表和目录结构所在的扇区,也照常进行。
返回值:0:成功;-1:失败。
头文件:dos.h函数3。
atof()将字符串转换成浮点数的函数原形:double atof(const char *s)功能:把s所指向的字符串转换成double类型。
s格式为:符号数字.数字E符号数字返回值:字符串的转换值。
头文件:math.h、stdlib.h函数4。
atoi()将字符串转换成整型数的函数原形:int atoi(const char *s)功能:把s所指向的字符串转换成int类型。
s格式为:符号数字返回值:字符串的转换值。
若出错则返回0。
头文件:stdlib.h函数5。
atol()将字符串转换成长整型数的函数原形:long atol(const char *s)功能:把s所指向的字符串转换成long int类型。
s格式为:符号数字返回值:字符串的转换值。
C语言函数大全

C语言函数大全C语言作为一种广泛应用的计算机编程语言,其函数是程序设计中不可或缺的部分。
C语言函数大全涵盖了C语言中常用的各种函数,包括数学函数、字符串函数、输入输出函数等,本文将对这些函数进行详细介绍。
一、数学函数。
1. abs函数。
abs函数用于返回一个整数的绝对值,其原型为int abs(int x)。
2. pow函数。
pow函数用于计算一个数的幂,其原型为double pow(double x, double y)。
3. sqrt函数。
sqrt函数用于计算一个数的平方根,其原型为double sqrt(double x)。
4. sin函数。
sin函数用于计算一个角度的正弦值,其原型为double sin(double x)。
5. cos函数。
cos函数用于计算一个角度的余弦值,其原型为double cos(double x)。
6. tan函数。
tan函数用于计算一个角度的正切值,其原型为double tan(double x)。
二、字符串函数。
1. strlen函数。
strlen函数用于返回一个字符串的长度,其原型为size_t strlen(const char s)。
2. strcpy函数。
strcpy函数用于将一个字符串复制到另一个字符串中,其原型为charstrcpy(char dest, const char src)。
3. strcat函数。
strcat函数用于将一个字符串追加到另一个字符串的末尾,其原型为char strcat(char dest, const char src)。
4. strcmp函数。
strcmp函数用于比较两个字符串,其原型为int strcmp(const char s1, const char s2)。
5. strchr函数。
strchr函数用于在一个字符串中查找指定字符的位置,其原型为charstrchr(const char s, int c)。
c#函数大全

1到9的平方和static void Main(string[] args){int h=0;for(int i=1;i<=9;i++){h=h+i*i;}Console.WriteLine (h);}1到100的累加static void Main(string[] args){ int sum = 0;for (int i = 1;i<=100;i++)sum = sum +i;Console.WriteLine("1到的累加总合为:{0}",sum);}}}10个行输出被7整除的数static void Main(string[] args){for(int i=100;i<=200;i++)for(int j=1;j<=10;j++) {if(i%7==0){ Console.Write ("{0}",i);break;}}7行倒三角for(int a=1;a<=7;a++){for(int b=1;b<=a;b++)Console.Write (" ");for(int c=1;c<=15-2*a;c++) {Console.Write ("*");}Console.Write ("\n");}乘法口诀表static void Main(string[] args){ int i,j; Console.WriteLine ("成法口决表");for(i=1;i<=9;i++){ for(j=1;j<=i;j++){ Console.Write("{0}*{1}={2};",j,i,(i*j));}Console.WriteLine ();}}}10的阶乘static void Main(string[] args){ int i=1; int n=1;do{ n=n*i;i++;}while (i<=10);Console.WriteLine ("10的阶乘结果为;{0}",n);}}For 循环求i的值static void Main(string[] args){ double s=0,x=1; //初始化for (int n=1;Math.Abs (x)>1e-8;n++,x*=(-1.0)*(2*n-3)/(2*n-1))s=s+x; s=s*4;Console.WriteLine ("pi的值是:{0}",s);}While循环求pi的值static void Main(string[] args){ double result =0,initial=1;//初始值 long deno = 1;int flag =1; while (Math.Abs (initial)>1e-8) //循环条件{ result =result+initial; //循环体,计算(Math.PI/4)deno=deno+2;flag=flag*(-1);initial=flag/Convert.ToDouble (deno);} result=result*4; //Math.PI值Console.WriteLine ("pi值是:{0}",result); //输出Math.PI值}}While 循环输出10的阶乘static void Main(string[] args){ int i=1; int n=1; while(i<=10){ n=n*i;i++;}Console.WriteLine ("10的阶乘结果为:{0}",n);}}百钱买百鸡static void Main(string[] args) {for(int g=0;g<20;g++) for(int m=0;m<35;m++) for(intx=0;x<100;x++){ if((g+m+x==100)&&(5*g+3*m+1/(3*x)==100))Console.WriteLine("值为;{0}\n 值为:{1}\n 值:{2}",g,m,x); }} }水仙花static void Main(string[] args) {int x=Convert.ToInt32 (Console.ReadLine ());int y=Convert.ToInt32 (Console.ReadLine ());int z=Convert.ToInt32 (Console.ReadLine ());if(x*100+y*10+z==x*x*x+y*y*y+z*z*z) Console.WriteLine ("水仙花");else Console.WriteLine ("不是水仙花");}}找6ji42能被两个数整除static void Main(string[] args){for(int j=0;j<=9;j++){ for(int i=0;i<=9;i++) {intx=60000+j*1000+i*100+42;if(x%32==0&&x%42==0) Console.WriteLine(x);}} }}正三角形的星using System;class Music{ static void Main(string[] args) { int i,j,b;捉司机using System;namespace ConsoleApplication1{class Class1 {static void Main(string[] args){int x=0;int y=0;for(x=0;x<=9;x++)for(y=0;y<=9;y++){double m=1000*x+100*x+10*y+y;for(int i=10;i<=100;i++)if(m==i*i)Console.WriteLine (m);}}}输出100到200中所有的素数static void Main(string[] args){ for(int i=100;i<=200;i++){ for(int j=2;j<=i;j++){if(i%j==0) break;if(j==i-1)Console.Write(i+"\t"); }}}}求2到10000间的完数static void Main(string[] args){ for (int j=2;j<=10000;j++){ int s=0;for(int i=1;i<j;i++){ if(j%i==0)s=s+i;}if(s==j) Console.WriteLine (j);} }}求两个数的最大公约数static void Main(string[] args){while(true){int a=Convert.ToInt32 (Console.ReadLine ());int b=Convert.ToInt32 (Console.ReadLine ()); if(a>b){ for(int c=a;c>0;c--){if(a%c==0&&b%c==0){ Console.WriteLine (c); break;}}}}}}判断输入的数是否为素数static void Main(string[] args){ while(true){int i; int x=Convert.ToInt32 (Console.ReadLine ()); for( i=2;i<x;i++){ if(x%i==0)Console.WriteLine ("x不是素数");break;}if( i==(x-1)) Console.WriteLine ("x是素数");}}}二原方程根的情况static void Main(string[] args){ double x1,x2; int a=Convert.ToInt32(Console.ReadLine()); int b=Convert.ToInt32(Console.ReadLine());int c=Convert.ToInt32(Console.ReadLine());doubled=b*b-4*a*c;if(a==0) Console.WriteLine("不是二元方程");if(d>0){ x1=(-b+System.Math.Sqrt(d))/(2*a);x2=(-b-System.Math.Sqrt(d))/(2*a);Console.WriteLine("第一个根:{0}\t第二个根:{1}\t",x1,x2);}if(d==0){ x1=-b/(2*a); x2=-b/(2*a); Console.WriteLine("第一个根:{0}\t第二个根:{1}\t",x1,x2);}} 歌德巴赫猜想static void Main(string[] args){ int m=Convert.ToInt32 (Console.ReadLine ());for(int x=6;x<m;x+=2){ for(int y=3;y<x/2;y++) if(prime(y)){int z=x-y;if(prime(z))Console.WriteLine ("结果为:x={0},y={1},z={2}",x,y,z); }}}static bool prime (int n){int i; for(i=2;i<=System.Math.Sqrt (n);i++) if(n%i==0)return false;return true;}}递归函数算任意数的阶乘static void Main(string[] args) { Console.WriteLine ("输入任意的数");int n=Convert.ToInt32 (Console.ReadLine ());double s=f(n);Console.WriteLine (f(n)); }static double f(int n){ double d=0;if(n==0||n==1) d=1; else d=f(n-1)*n;return d;}}函数比较三个数的大小static void Main(string[] args){int result=MaxThree(2,7,4); Console.WriteLine (result); }static int MaxTwo(int x,int y){ if(x>y) return x;else return y; }static int MaxThree(int x,int y,int z){ int temp;temp=MaxTwo(x,y);if(z>temp)return z;else return temp;}}}调用编成世界using System;namespace ConsoleApplication11{class Class1{static void Main(string[] args){string name =Convert.ToString(Console.ReadLine()); welcome( name); }static void welcome(string name){ for(int i=1;i<=5;i++)Console.WriteLine("欢迎你,{0}同志,这里是C#编程世界",name);}}大小写字母转换char c=Convert.ToChar(Console.ReadLine());if(c>='a'&&c<='z'){int b=(int)c-32;char ch=(char)b;Console.WriteLine(ch);}if(c>='A'&&c<='Z'){int d=(int)c+32;char ch=(char)d;Console.WriteLine(ch);}判断瑞年int year=Convert.ToInt32(Console.ReadLine());if(year%4==0&&year%100==0)//[if(year%400==0) ]Console.WriteLine("瑞年");elseConsole.WriteLine("不是瑞年");求最小公倍数int a=Convert.ToInt32 (Console.ReadLine());int b=Convert.ToInt32 (Console.ReadLine ());int d=Convert.ToInt32 (Console.ReadLine ());if(a>b&&a>d){for(int c=a;c>0;c--){if(c%a==0&&c%b==0&&c%d==0){Console.WriteLine (c);break;}正三角形的星using System;class Music{ static void Main(string[] args){ int i,j,b; for( i=1;i<=4;i++){ for(j=0;j<=4-i;j++) Console.Write(" ");for(b=1;b<=2*i-1;b++) Console.Write("*"); Console.Write("\n"); }}namespace ConsoleApplication1{ class Program { static void Main(string[] args){实验五第一题输入月号,输出月份的英文名称do {Console.WriteLine("请输入您需要的月份:");Console.WriteLine ("下面的程序将对它进行英文翻译."); int a=Convert.ToInt16 (Console.ReadLine ());switch(a){case(1): Console.WriteLine ("Jan");break; case(2):Console.WriteLine ("Feb");break;case(3): Console.WriteLine ("Mar");break;case(4): Console.WriteLine ("Apr");break;case(5):Console.WriteLine("May");break;case(6):Console.WriteLine ("Jun");break;case(7): Console.WriteLine ("Jul");break;case(8):Console.WriteLine ("Aug");break;case(9): Console.WriteLine ("Sep");break;case(10): Console.WriteLine ("Oct");break;case(11):Console.WriteLine ("Nov");break;case(12):Console.WriteLine ("Der");break;}}while(true); Console.ReadLine ();实验五第二题托儿所问题Console.WriteLine("请输入你的年龄大小:");int a =Convert.ToInt16(Console .ReadLine ());switch (a){ case (2): Console.WriteLine("please enter lower class"); break;case(3):Console.WriteLine("please enter lower class"); break;case(4): Console .WriteLine ("please enter middle class"); break;case(5): Console.WriteLine("please enter higher class"); break;case(6): Console .WriteLine ("please enter higher class"); break;}Console .ReadLine ();实验五第三题开发一个数学工具do{Console.WriteLine("欢迎使用本数学工具,本数学工具具有以下功能");Console.WriteLine("图形面积计算按1");Console.WriteLine("算术计算按2");Console.WriteLine("三角函数计算按3");Console.WriteLine("请输入数字选择您此次计算的类型");int x = int.Parse(Console.ReadLine());double area, v;switch (x){case (1):{Console.WriteLine("请输入字母选择您此次计算的图形面积的类型");Console.WriteLine("三角形的面积按1:"); Console.WriteLine("长方形的面积按2:");Console.WriteLine("圆形的面积按3:"); Console.WriteLine("梯形的面积按4:");int y = int.Parse(Console.ReadLine());switch (y){ case (1):{Console.WriteLine("请输入三角形的边q:");Console.WriteLine("请输入三角形的边p:");Console.WriteLine("请输入三角形的边l:");double q = Convert.ToInt64(Console.ReadLine());double p = double.Parse(Console.ReadLine());double l = double.Parse(Console.ReadLine());double h;if ((q + p) > l && (q + l) > p && (l + p) > q){ h = (1 / 2) * (q + p + l);rea = Math.Sqrt(h * (h - q) * (h - p) * (h - l));Console.WriteLine("面积="+area); }else{ Console.WriteLine("输入三边错误不能够成三角形");}break; }case (2):{Console.WriteLine("请输入长方形的短边q:"); Console.WriteLine("请输入长方形的长边p:");double q = Convert.ToInt64(Console.ReadLine()); double p = double.Parse(Console.ReadLine());area = q * p;Console.WriteLine("面积:"+area); break;}case (3):{Console.WriteLine("请输入园的半径q:");double q = Convert.ToInt64(Console.ReadLine()); area = q * q * Math.PI;Console.WriteLine("面积:"+area);break;}case (4):{Console.WriteLine("请输入上底的长度q:");Console.WriteLine("请输入下底的长度p:");Console.WriteLine("请输入高的长度h:");double q = Convert.ToInt64(Console.ReadLine());double p = double.Parse(Console.ReadLine());double h = double.Parse(Console.ReadLine());area = ((q + p) * h) / 2;Console.WriteLine("面积:"+area);break;}}break;}case (2):{Console.WriteLine("要算加法请输入1:");Console.WriteLine("要算减法请输入2:");Console.WriteLine("要算乘法请输入3:");Console.WriteLine("要算除法请输入4:");int k = Convert.ToInt16(Console.ReadLine());switch (k){ case (1):{ Console.WriteLine("请输入q:"); Console.WriteLine("请输入p:");double q = Convert.ToInt64(Console.ReadLine());double p = double.Parse(Console.ReadLine());v = q + p;Console.WriteLine("两数和:"+v); break; }case (2):{Console.WriteLine("请输入较大数q:");Console.WriteLine("请输入较小数p:");double q = Convert.ToInt64(Console.ReadLine());double p = double.Parse(Console.ReadLine());v = q - p;Console.WriteLine("两数差:"+v); break;}case (3):{Console.WriteLine("请输入被除数q:");Console.WriteLine("请输入除数p:");double q = Convert.ToInt64(Console.ReadLine());double p = double.Parse(Console.ReadLine());v = q / p;Console.WriteLine("两数商:" + v);break;}case (4):{Console.WriteLine("请输入其中要乘的数一q:");Console.WriteLine("请输入另一个乘数二p:"); double q = Convert.ToDouble(Console.ReadLine());double p = double.Parse(Console.ReadLine());v = q * p;Console.WriteLine("两数积:"+v); break;} }break;}case (3):{ Console.WriteLine("要想求sin请输入1:");Console.WriteLine("要想求cos请输入2:");Console.WriteLine("要想求tan请输入3:"); int m = Convert.ToInt16(Console.ReadLine());switch (m){case (1):{Console.WriteLine("请输入您的度数:");double q= double .Parse (Console .ReadLine ());q=Math.Sin ();Console.WriteLine(m);break;}case (2):{Console.WriteLine("请输入您的度数:");double q = Convert .ToInt64 (Console.ReadLine());q = Math.Cos();Console.WriteLine(q); break; }case (3):{Console.WriteLine("请输入您的度数:");double q = Convert .ToDouble (Console.ReadLine()); q = Math.Tan();Console.WriteLine(q);break; }}break;} while(true); Console.ReadLine();}}}试验七第一题求e的值double i, n=1;double sum=0;for (i = 1; i <= 10; i++){ n = n*i;sum = sum + 1/n ; Console.WriteLine(sum); }Console.ReadLine();实验七第二题方法一m和n的最大公约数int i,temp=0;Console.WriteLine("请输入您的数a:");int a = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("请输入您的数b");int b = Convert.ToInt32(Console.ReadLine());for (i = 1; i <=a && i<= b; i++){ if ((a % i == 0) && (b % i == 0)) temp = i;} Console .WriteLine (temp); //Console.ReadLine();/ 实验七第三题人口增长率Console.WriteLine("该程序有三种%数,分别是%5,%2,%1。
C语言常用的库函数表

附录C C语言常用的库函数
库函数并不是C语言的一部分,它是由编译系统根据一般用户的需要编制并提供给用户使用的一组程序;每一种C编译系统都提供了一批库函数,不同的编译系统所提供的库函数的数目和函数名以及函数功能是不完全相同的;ANSI C标准提出了一批建议提供的标准库函数;它包括了目前多数C编译系统所提供的库函数,但也有一些是某些C编译系统未曾实现的;考虑到通用性,本附录列出ANSI C建议的常用库函数;
由于C库函数的种类和数目很多,例如还有屏幕和图形函数、时间日期函数、与系统有关的函数等,每一类函数又包括各种功能的函数,限于篇幅,本附录不能全部介绍,只从教学需要的角度列出最基本的;读者在编写C程序时可根据需要,查阅有关系统的函数使用手册;
1.数学函数
使用数学函数时,应该在源文件中使用预编译命令:
2.字符函数
在使用字符函数时,应该在源文件中使用预编译命令:
3.字符串函数
使用字符串中函数时,应该在源文件中使用预编译命令:
4.输入输出函数
在使用输入输出函数时,应该在源文件中使用预编译命令:
5.动态存储分配函数
在使用动态存储分配函数时,应该在源文件中使用预编译命令:include <stdlib.h>或include "stdlib.h"
6.其他函数
有些函数由于不便归入某一类,所以单独列出;使用这些函数时,应该在源文件中使用预编译命令:。
C语言常用数学函数

常用数学函数abs(计算整型数的绝对值)相关函数labs, fabs表头文件#include<stdlib.h>定义函数int abs (int j)函数说明abs()用来计算参数j的绝对值,然后将结果返回。
返回值返回参数j的绝对值结果。
范例#ingclude <stdlib.h>main(){int ansert;answer = abs(-12);printf("|-12| = %d\n", answer);}执行|-12| = 12acos(取反余弦函数数值)相关函数asin , atan , atan2 , cos , sin , tan表头文件#include <math.h>定义函数double acos (double x);函数说明acos()用来计算参数x的反余弦值,然后将结果返回。
参数x范围为-1至1之间,超过此范围则会失败。
返回值返回0至PI之间的计算结果,单位为弧度,在函数库中角度均以弧度来表示。
错误代码EDOM参数x超出范围。
附加说明使用GCC编译时请加入-lm。
范例#include <math.h>main (){double angle;angle = acos(0.5);printf("angle = %f\n", angle);}执行angle = 1.047198asin(取反正弦函数值)相关函数acos , atan , atan2 , cos , sin , tan表头文件#include <math.h>定义函数double asin (double x)函数说明asin()用来计算参数x的反正弦值,然后将结果返回。
参数x范围为-1至1之间,超过此范围则会失败。
返回值返回-PI/2之PI/2之间的计算结果。
错误代码EDOM参数x超出范围附加说明使用GCC编译时请加入-lm范例#include<math.h>main(){double angle;angle = asin (0.5);printf("angle = %f\n",angle);}执行angle = 0.523599atan(取反正切函数值)相关函数acos,asin,atan2,cos,sin,tan表头文件#include<math.h>定义函数double atan(double x);函数说明atan()用来计算参数x的反正切值,然后将结果返回。
C语言~所有的字符串操作函数

7.函数名: strcspn 功 能: 在串中查找第一个给定字符集内容的段 用 法: int strcspn(char *str1, char *str2); 程序例: #i nclude <stdio.h> #i nclude <string.h> #i nclude <alloc.h> int main(void) { char *string1 = "1234567890"; char *string2 = "747DC8"; int length;
printf("buffer 2 is greater than buffer 1\n"); if (ptr < 0)
printf("buffer 2 is less than buffer 1\n"); if (ptr == 0)
printf("buffer 2 equals buffer 1\n"); return 0; }
printf("buffer 2 is less than buffer 1\n"); if (ptr == 0)
printf("buffer 2 equals buffer 1\n"); return 0; }
14.函数名: strncpy 功 能: 串拷贝 用 法: char *strncpy(char *destin, char *source, int maxlen); 程序例: #i nclude <stdio.h> #i nclude <string.h> int main(void) {
i--的用法c语言

i--的用法c语言i--是C语言中的一个操作符,被称为递减操作符。
它用于将一个变量的值减1、在C语言中,它可以用作前缀和后缀操作符,有不同的使用方式和语义。
1.前缀i--:先减后使用语法:--i使用前,先将i的值减1,然后再使用减少后的值。
例如:```cint i = 5;printf("%d\n", --i); //输出:4printf("%d\n", i); //输出:4```在这个例子中,i的值先被减1变成4,然后输出4、再次打印i的值还是42.后缀i--:先使用后减语法:i--使用i的当前值,然后再将i的值减1、例如:```cint i = 5;printf("%d\n", i--); //输出:5printf("%d\n", i); //输出:4```在这个例子中,打印出来的结果是5,然后才将i的值减1变成4、再次打印i的值就是4i--可以用于内存分配和循环控制等多种情况中,下面是一些常见的用法:1.内存分配```cint size = 10;int *ptr = (int*)malloc(size * sizeof(int));for (int i = size-1; i >= 0; i--)ptr[i] = 0;}```这个例子中,通过递减操作符可以逆序初始化一段内存空间。
2.数组遍历```cint arr[] = {1, 2, 3, 4, 5};int length = sizeof(arr) / sizeof(arr[0]);for (int i = length-1; i >= 0; i--)printf("%d ", arr[i]);}```这个例子中,i--被用于逆序遍历数组的索引,将数组元素从后往前依次打印出来。
3.循环控制```cfor (int i = 10; i > 0; i--)printf("%d\n", i);}```这个例子中,通过递减操作符将循环变量i的值从10递减到1,实现了倒计时的效果。
c语言常用函数大全及详解

C语言常用函数包括:1.printf函数:用于在控制台输出数据。
2.scanf函数:用于从控制台读取用户输入的数据。
3.strlen函数:用于计算字符串的长度。
4.strcmp函数:用于比较两个字符串的大小。
5.strcpy函数:用于将一个字符串复制到另一个字符串中。
6.strcat函数:用于将一个字符串连接到另一个字符串的末尾。
7.strchr函数:用于查找字符串中指定字符的位置。
8.strstr函数:用于查找字符串中指定子串的位置。
9.atoi函数:用于将字符串转换为整数。
10.atof函数:用于将字符串转换为浮点数。
11.malloc函数:用于动态分配内存空间。
12.free函数:用于释放动态分配的内存空间。
13.memcpy函数:用于将一段内存区域的数据复制到另一段内存区域。
14.memset函数:用于将一段内存区域的数据设置为指定的值。
15.abs函数:用于计算整数的绝对值。
16.rand函数:用于生成随机数。
17.srand函数:用于设置随机数生成器的种子。
18.time函数:用于获取当前的系统时间。
19.localtime函数:用于将时间戳转换为本地时间。
20.strtol函数:用于将字符串转换为长整型数。
21.strtod函数:用于将字符串转换为双精度浮点数。
22.fprintf函数:用于将数据格式化输出到文件中。
23.fscanf函数:用于从文件中读取格式化的数据。
24.fgets函数:用于从文件中读取一行数据。
25.fputs函数:用于将数据写入文件中。
26.fopen函数:用于打开文件。
27.fclose函数:用于关闭文件。
28.feof函数:用于判断文件是否已经到达文件末尾。
29.ferror函数:用于判断文件操作是否发生错误。
30.fprintf函数:用于将数据格式化输出到文件中。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
函数名: labs
用法: long labs(long n);
程序例:
#include #include int main(void) { long result; long x = -12345678L; result= labs(x); printf("number: %ld abs value: %ld\n", x, result); return 0; }
函数名: log10
功能: 对数函数 log
用法: double log10(double x);
程序例:
#include #include int main(void) { double result; double x = 800.6872; result = log10(x); printf("The common log of %lf is %lf\n", x, result); return 0; }
函数名: lock
功能: 设置文件共享锁
用法: int lock(int handle, long offset, long length);
程序例:
#include #include #include #include #include #include int main(void) { int handle, status; long length; /* Must have DOS Share.exe loaded for */
函数名: ldexp
功能: 计算 value*2的幂
用法: double ldexp(double value, int exp);
程序例:
#include #include int main(void) { double value; double x = 2; /* ldexp raises 2 by a power of 3 then multiplies the result by 2 */ value = ldexp(x,3); printf("The ldexp value is: %lf\n", value); return 0; }
函数名: lfind
功能: 执行线性搜索
用法: void *lfind(void *key, void *base, int *nelem, int width,
int (*fcmp)());
程序例:
#include #include int compare(int *x, int *y) { return( *x - *y ); } int main(void) { int array[5] = {35, 87, 46, 99, 12}; size_t nelem = 5; int key; int *result; key = 99; result = lfind(&key, array, &nelem, sizeof(int), (int(*)(const void *,const void *))compare); if (result) printf("Number %d found\n",key); else
函数名: log
功能: 对数函数 ln(x)
用法: double log(double x);
程序例:
#include #include int main(void) { double result; double x = 8.6872; result = log(x); printf("The natural log of %lf is %lf\n", x, result); return 0; }
/* lrotl example */ #include #include int main(void) { unsigned long result; unsigned long value = 100; result = _lrotl(value,1); printf("The value %lu rotated left one bit is: %lu\n", value, result); return 0; }
函数名: lowvideo
功能: 选择低亮度字符
用法: void lowvideo(void);
程序例:
#include int main(void) { clrscr(); highvideo(); cprintf("High Intesity Text\r\n"); lowvideo(); gotoxy(1,2); cprintf("Low Intensity Text\r\n"); return 0; }
函数名: longjump
功能: 执行非局部转移
用法: void longjump(jmp_buf env, int val);
程序例:
#include #include #include void subroutine(jmp_buf); int main(void) { int value; jmp_buf jumper; value = setjmp(jumper); if (value != 0) { printf("Longjmp with value %d\n", value); exit(value); }QQ291911320 printf("About to call subroutine ... \n"); subroutine(jumper); return 0; } void subroutine(jmp_buf jumper) { longjmp(jumper,1); }
/* file locking to function properly */ handle = sopen("c:\\autoexec.bat", O_RDONLY,SH_DENYNO,S_IREAD); if (handle < 0) { printf("sopen failed\n"); exit(1); } length = filelength(handle); status = lock(handle,0L,length/2); if (status == 0) printf("lock succeeded\n"); else printf("lock failed\n"); status = unlock(handle,0L,length/2); if (status == 0) printf("unlock succeeded\n"); else printf("unlock failed\n"); close(handle); return 0; }
函数名: lrotl, _lrotl
功能: 将无符号长整型数向左循环移位
用法: unsigned long lrotl(unsigned long lvalue, int count);
unsigned long _lrotl(unsigned long lvalue, int count);
程序例:
函数名: linerel
功能: 从当前位置点(CP)到与 CP 有一给定相对距离的点画一直线
用法: void far linerel(int dx, int dy);
程序例:
#include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; char msg[80]; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } /* move the C.P. to location (20, 30) */ moveto(20, 30); /* create and output a message at (20, 30) */ sprintf(msg, " (%d, %d)", getx(), gety()); outtextxy(20, 30, msg); /* draw a line to a point a relative distance away from the current value of C.P. */ linerel(100, 100); /* create and output a message at C.P. */ sprintf(msg, " (%d, %d)", getx(), gety()); outtext(msg); /* clean up */ getch(); closegraph();
函数名: ldiv
功能: 两个长整型数相除, 返回商和余数
用法: ldiv_t ldiv(long lnumer, long ldenom);
程序例:
/* ldiv example */ #include #include int main(void) { ldiv_t lx; lx = ldiv(100000L, 30000L); printf("100000 div 30000 = %ld remainder %ld\n", lx.quot, lx.rem); return 0caltime