资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

小甲鱼c语言的函数大全 小甲鱼c语言100道例题

c语言的图形函数库有哪些

图形和图像函数包含在graphics.h里面(一) 像素函数56. putpiel() 画像素点函数57. getpixel()返回像素色函数(二) 直线和线型函数58. line() 画线函数59. lineto() 画线函数60. linerel() 相对画线函数61. setlinestyle() 设置线型函数62. getlinesettings() 获取线型设置函数63. setwritemode() 设置画线模式函数(三)、多边形函数64. rectangle() 画矩形函数65. bar() 画条函数66. bar3d() 画条块函数67. drawpoly() 画多边形函数(四)、 圆、弧和曲线函数68. getaspectratio()获取纵横比函数69. circle()画圆函数70. arc() 画圆弧函数71. ellipse()画椭圆弧函数72. fillellipse() 画椭圆区函数73. pieslice() 画扇区函数74. sector() 画椭圆扇区函数75. getarccoords()获取圆弧坐标函数(五)、 填充函数76. setfillstyle() 设置填充图样和颜色函数77. setfillpattern() 设置用户图样函数78. floodfill() 填充闭域函数79. fillpoly() 填充多边形函数80. getfillsettings() 获取填充设置函数81. getfillpattern() 获取用户图样设置函数(六)、图像函数82. imagesize() 图像存储大小函数83. getimage() 保存图像函数84. putimage() 输出图像函数四、图形和图像函数对许多图形应用程序,直线和曲线是非常有用的。但对有些图形只能靠操作单个像素才能画出。当然如果没有画像素的功能,就无法操作直线和曲线的函数。而且通过大规模使用像素功能,整个图形就可以保存、写、擦除和与屏幕上的原有图形进行叠加。(一) 像素函数56. putpixel() 画像素点函数功能: 函数putpixel() 在图形模式下屏幕上画一个像素点。用法: 函数调用方式为void putpixel(int x,int y,int color);说明: 参数x,y为像素点的坐标,color是该像素点的颜色,它可以是颜色符号名,也可以是整型色彩值。此函数相应的头文件是graphics.h返回值: 无例: 在屏幕上(6,8)处画一个红色像素点:putpixel(6,8,RED);57. getpixel()返回像素色函数功能: 函数getpixel()返回像素点颜色值。用法: 该函数调用方式为int getpixel(int x,int y);说明: 参数x,y为像素点坐标。函数的返回值可以不反映实际彩色值,这取决于调色板的设置情况(参见setpalette()函数)。这个函数相应的头文件为graphics.h返回值: 返回一个像素点色彩值。例: 把屏幕上(8,6)点的像素颜色值赋给变量color。color=getpixel(8,6);

创新互联公司:从2013年创立为各行业开拓出企业自己的“网站建设”服务,为上1000家公司企业提供了专业的网站建设、网站制作、网页设计和网站推广服务, 按需搭建网站由设计师亲自精心设计,设计的效果完全按照客户的要求,并适当的提出合理的建议,拥有的视觉效果,策划师分析客户的同行竞争对手,根据客户的实际情况给出合理的网站构架,制作客户同行业具有领先地位的。

求C语言函数大全

函数名: abort

功 能: 异常终止一个进程

用 法: void abort(void);

程序例:

#include stdio.h

#include stdlib.h

int main(void)

{

printf("Calling abort()\n");

abort();

return 0; /* This is never reached */

}

函数名: abs

功 能: 求整数的绝对值

用 法: int abs(int i);

程序例:

#include stdio.h

#include math.h

int main(void)

{

int number = -1234;

printf("number: %d absolute value: %d\n", number, abs(number));

return 0;

}

函数名: absread, abswirte

功 能: 绝对磁盘扇区读、写数据

用 法: int absread(int drive, int nsects, int sectno, void *buffer);

int abswrite(int drive, int nsects, in tsectno, void *buffer);

程序例:

/* absread example */

#include stdio.h

#include conio.h

#include process.h

#include dos.h

int main(void)

{

int i, strt, ch_out, sector;

char buf[512];

printf("Insert a diskette into drive A and press any key\n");

getch();

sector = 0;

if (absread(0, 1, sector, buf) != 0)

{

perror("Disk problem");

exit(1);

}

printf("Read OK\n");

strt = 3;

for (i=0; i80; i++)

{

ch_out = buf[strt+i];

putchar(ch_out);

}

printf("\n");

return(0);

}

函数名: access

功 能: 确定文件的访问权限

用 法: int access(const char *filename, int amode);

程序例:

#include stdio.h

#include io.h

int file_exists(char *filename);

int main(void)

{

printf("Does NOTEXIST.FIL exist: %s\n",

file_exists("NOTEXISTS.FIL") ? "YES" : "NO");

return 0;

}

int file_exists(char *filename)

{

return (access(filename, 0) == 0);

}

函数名: acos

功 能: 反余弦函数

用 法: double acos(double x);

程序例:

#include stdio.h

#include math.h

int main(void)

{

double result;

double x = 0.5;

result = acos(x);

printf("The arc cosine of %lf is %lf\n", x, result);

return 0;

}

函数名: allocmem

功 能: 分配DOS存储段

用 法: int allocmem(unsigned size, unsigned *seg);

程序例:

#include dos.h

#include alloc.h

#include stdio.h

int main(void)

{

unsigned int size, segp;

int stat;

size = 64; /* (64 x 16) = 1024 bytes */

stat = allocmem(size, segp);

if (stat == -1)

printf("Allocated memory at segment: %x\n", segp);

else

printf("Failed: maximum number of paragraphs available is %u\n",

stat);

return 0;

}

函数名: arc

功 能: 画一弧线

用 法: void far arc(int x, int y, int stangle, int endangle, int radius);

程序例:

#include graphics.h

#include stdlib.h

#include stdio.h

#include conio.h

int main(void)

{

/* request auto detection */

int gdriver = DETECT, gmode, errorcode;

int midx, midy;

int stangle = 45, endangle = 135;

int radius = 100;

/* initialize graphics and local variables */

initgraph(gdriver, gmode, "");

/* read result of initialization */

errorcode = graphresult(); /* an error occurred */

if (errorcode != grOk)

{

printf("Graphics error: %s\n", grapherrormsg(errorcode));

printf("Press any key to halt:");

getch();

exit(1); /* terminate with an error code */

}

midx = getmaxx() / 2;

midy = getmaxy() / 2;

setcolor(getmaxcolor());

/* draw arc */

arc(midx, midy, stangle, endangle, radius);

/* clean up */

getch();

closegraph();

return 0;

}

函数名: asctime

功 能: 转换日期和时间为ASCII码

用 法: char *asctime(const struct tm *tblock);

程序例:

#include stdio.h

#include string.h

#include time.h

int main(void)

{

struct tm t;

char str[80];

/* sample loading of tm structure */

t.tm_sec = 1; /* Seconds */

t.tm_min = 30; /* Minutes */

t.tm_hour = 9; /* Hour */

t.tm_mday = 22; /* Day of the Month */

t.tm_mon = 11; /* Month */

t.tm_year = 56; /* Year - does not include century */

t.tm_wday = 4; /* Day of the week */

t.tm_yday = 0; /* Does not show in asctime */

t.tm_isdst = 0; /* Is Daylight SavTime; does not show in asctime */

/* converts structure to null terminated

string */

strcpy(str, asctime(t));

printf("%s\n", str);

return 0;

}

函数名: asin

功 能: 反正弦函数

用 法: double asin(double x);

程序例:

#include stdio.h

#include math.h

int main(void)

{

double result;

double x = 0.5;

result = asin(x);

printf("The arc sin of %lf is %lf\n", x, result);

return(0);

}

函数名: assert

功 能: 测试一个条件并可能使程序终止

用 法: void assert(int test);

程序例:

#include assert.h

#include stdio.h

#include stdlib.h

struct ITEM {

int key;

int value;

};

/* add item to list, make sure list is not null */

void additem(struct ITEM *itemptr) {

assert(itemptr != NULL);

/* add item to list */

}

int main(void)

{

additem(NULL);

return 0;

}

函数名: atan

功 能: 反正切函数

用 法: double atan(double x);

程序例:

#include stdio.h

#include math.h

int main(void)

{

double result;

double x = 0.5;

result = atan(x);

printf("The arc tangent of %lf is %lf\n", x, result);

return(0);

}

函数名: atan2

功 能: 计算Y/X的反正切值

用 法: double atan2(double y, double x);

程序例:

#include stdio.h

#include math.h

int main(void)

{

double result;

double x = 90.0, y = 45.0;

result = atan2(y, x);

printf("The arc tangent ratio of %lf is %lf\n", (y / x), result);

return 0;

}

函数名: atexit

功 能: 注册终止函数

用 法: int atexit(atexit_t func);

程序例:

#include stdio.h

#include stdlib.h

void exit_fn1(void)

{

printf("Exit function #1 called\n");

}

void exit_fn2(void)

{

printf("Exit function #2 called\n");

}

int main(void)

{

/* post exit function #1 */

atexit(exit_fn1);

/* post exit function #2 */

atexit(exit_fn2);

return 0;

}

函数名: atof

功 能: 把字符串转换成浮点数

用 法: double atof(const char *nptr);

程序例:

#include stdlib.h

#include stdio.h

int main(void)

{

float f;

char *str = "12345.67";

f = atof(str);

printf("string = %s float = %f\n", str, f);

return 0;

}

函数名: atoi

功 能: 把字符串转换成长整型数

用 法: int atoi(const char *nptr);

程序例:

#include stdlib.h

#include stdio.h

int main(void)

{

int n;

char *str = "12345.67";

n = atoi(str);

printf("string = %s integer = %d\n", str, n);

return 0;

}

函数名: atol

功 能: 把字符串转换成长整型数

用 法: long atol(const char *nptr);

程序例:

#include stdlib.h

#include stdio.h

int main(void)

{

long l;

char *str = "98765432";

l = atol(lstr);

printf("string = %s integer = %ld\n", str, l);

return(0);

}

c语言常用库函数有哪些

文件stddef.h里包含了标准库的一些常用定义,无论我们包含哪个标准头文件,stddef.h都会被自动包含进来。

这个文件里定义:

类型size_t (sizeof运算符的结果类型,是某个无符号整型);

类型ptrdiff_t(两个指针相减运算的结果类型,是某个有符号整型);

类型wchar_t (宽字符类型,是一个整型,其中足以存放本系统所支持的所有本地环境中的字符集的所有编码值。这里还保证空字符的编码值为0);

符号常量NULL (空指针值);

宏offsetor (这是一个带参数的宏,第一个参数应是一个结构类型,第二个参数应是结构成员名。 offsetor(s,m)求出成员m在结构类型t的变量里的偏移量)。


分享名称:小甲鱼c语言的函数大全 小甲鱼c语言100道例题
分享路径:http://cdkjz.cn/article/ddeispe.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220