墙角野猫
发表于 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);
}
墙角野猫
发表于 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;
}
墙角野猫
发表于 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);
}
墙角野猫
发表于 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;
}
墙角野猫
发表于 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;
}
墙角野猫
发表于 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;
}
墙角野猫
发表于 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;
}
墙角野猫
发表于 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);
}
墙角野猫
发表于 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;
}
墙角野猫
发表于 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;
}
页:
1
[2]
3
4
5
6
7
8
9
10
11