找回密码

碧海潮声大学生网

楼主: 墙角野猫
打印 上一主题 下一主题

c语言函数大全

[复制链接]
11#
 楼主| 发表于 2006-7-12 22:15 | 只看该作者
函数名: asin
功 能: 反正弦函数
用 法: double asin(double x);
程序例:
#include
#include
int main(void)
{
double result;
double x = 0.5;
result = asin(x);
printf("The arc sin of %lf is %lf
", x, result);
return(0);
}
12#
 楼主| 发表于 2006-7-12 22:16 | 只看该作者
函数名: assert
功 能: 测试一个条件并可能使程序终止
用 法: void assert(int test);
程序例:
#include
#include
#include
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;
}
13#
 楼主| 发表于 2006-7-12 22:16 | 只看该作者
函数名: atan
功 能: 反正切函数
用 法: double atan(double x);
程序例:
#include
#include
int main(void)
{
double result;
double x = 0.5;
result = atan(x);
printf("The arc tangent of %lf is %lf
", x, result);
return(0);
}
14#
 楼主| 发表于 2006-7-12 22:17 | 只看该作者
函数名: atan2
功 能: 计算Y/X的反正切值
用 法: double atan2(double y, double x);
程序例:
#include
#include
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
", (y / x), result);
return 0;
}
15#
 楼主| 发表于 2006-7-12 22:18 | 只看该作者
函数名: atexit
功 能: 注册终止函数
用 法: int atexit(atexit_t func);
程序例:
#include
#include
void exit_fn1(void)
{
printf("Exit function #1 called
");
}
void exit_fn2(void)
{
printf("Exit function #2 called
");
}
int main(void)
{
/* post exit function #1 */
atexit(exit_fn1);
/* post exit function #2 */
atexit(exit_fn2);
return 0;
}
16#
 楼主| 发表于 2006-7-12 22:19 | 只看该作者
函数名: atof
功 能: 把字符串转换成浮点数
用 法: double atof(const char *nptr);
程序例:
#include
#include
int main(void)
{
float f;
char *str = "12345.67";
f = atof(str);
printf("string = %s float = %f
", str, f);
return 0;
}
17#
 楼主| 发表于 2006-7-12 22:19 | 只看该作者
函数名: atoi
功 能: 把字符串转换成长整型数
用 法: int atoi(const char *nptr);
程序例:
#include
#include
int main(void)
{
int n;
char *str = "12345.67";
n = atoi(str);
printf("string = %s integer = %d
", str, n);
return 0;
}
18#
 楼主| 发表于 2006-7-12 22:22 | 只看该作者
函数名: atol
功 能: 把字符串转换成长整型数
用 法: long atol(const char *nptr);
程序例:
#include
#include
int main(void)
{
long l;
char *str = "98765432";
l = atol(lstr);
printf("string = %s integer = %ld
", str, l);
return(0);
}
19#
 楼主| 发表于 2006-7-12 22:23 | 只看该作者
函数名: bar
功 能: 画一个二维条形图
用 法: void far bar(int left, int top, int right, int bottom);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy, i;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s
", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* loop through the fill patterns */
for (i=SOLID_FILL; i {
/* set the fill style */
setfillstyle(i, getmaxcolor());
/* draw the bar */
bar(midx-50, midy-50, midx+50,
midy+50);
getch();
}
/* clean up */
closegraph();
return 0;
}
20#
 楼主| 发表于 2006-7-12 22:23 | 只看该作者
函数名: bar3d
功 能: 画一个三维条形图
用 法: void far bar3d(int left, int top, int right, int bottom,
int depth, int topflag);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy, i;
/* initialize graphics, local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s
", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* loop through the fill patterns */
for (i=EMPTY_FILL; i {
/* set the fill style */
setfillstyle(i, getmaxcolor());
/* draw the 3-d bar */
bar3d(midx-50, midy-50, midx+50, midy+50, 10, 1);
getch();
}
/* clean up */
closegraph();
return 0;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋| 碧海潮声大学生网  

Copyright © 2001-2013 Comsenz Inc.   All Rights Reserved.

Powered by Discuz! X3.2( 浙ICP备11026473号 )

快速回复 返回顶部 返回列表