数学建模社区-数学中国

标题: 函数大全(n ,o开头) [打印本页]

作者: 韩冰    时间: 2004-10-4 02:56
标题: 函数大全(n ,o开头)
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(n ,o开头)</FONT></B></FONT></P>( S2 W" t/ ]; S  ^) t7 f% C
<><FONT color=#ff0000>void normvideo(void );4 r7 n& U3 G. G/ |
</FONT>选择正常亮度字符。  w' K7 U9 [# q4 {% _2 P% l" c
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
2 k: K' Z+ }. C! z' X) n& a) s; ]1 A0 }" f, v$ b

+ R! |5 r1 g" a* w2 J  Q0 Z7 H! O5 c<><FONT color=#ff0000>void nosound(void );
! t1 x  ^7 V+ d</FONT>关闭由调用 sound而发声的扬声器。
: P* S5 e4 U4 r/ p( S0 Q</P>% O3 [9 N- D$ C! z( p- U
<><FONT color=#ff0000>函数名: open </FONT>
' h/ r9 I* A0 {1 z0 _3 v( C+ ?功 能: 打开一个文件用于读或写
8 j0 s2 i8 z% l# x用 法: int open(char *pathname, int access[, int permiss]);
/ K; M6 b, ^& G' a% F程序例: </P>
3 S* @1 p7 E3 b1 ^5 D: y; {<><FONT color=#0000ff>#include <STRING.H>
+ ]3 B! W7 B, l! e7 ~, `#include <STDIO.H>
( q7 J  f0 b4 Y* k4 c# W. [+ _( g/ F: M, ~#include <FCNTL.H>7 A0 h; u7 L3 e% w1 A% }
#include <IO.H></FONT></P>9 {+ |9 F- W5 v5 }9 k# T! J4 w
<><FONT color=#0000ff>int main(void)
8 T) _* m) P. A: k" i" s{
* m  p5 Y5 o8 P+ tint handle; , S  k8 d( v6 A/ ^7 C
char msg[] = "Hello world"; </FONT></P>" J2 x  |- k$ T  }
<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
; @0 n( `6 z/ U) H8 \  s{ & q* v6 y( _: g# D0 B
perror("Error:");
0 B0 G4 h  @8 L& ~0 I5 ireturn 1; 9 `# |1 N, {' ^6 x
} 2 Z5 C& l: U( y1 h- v' _9 C6 X
write(handle, msg, strlen(msg)); ' ^/ G7 k5 \7 c- y& ^) _
close(handle); ( |4 \9 K  X" S  X: D
return 0;
& _! c! I- }  O, }2 m} ) h3 ?9 j1 e  ]* j: C# f' A6 \
</FONT>3 x1 U# i8 J; r6 O4 W
</P>
" K9 }. N) f2 B6 Q& {<><FONT color=#ff0000>函数名: outport </FONT>0 G, Z0 w  g" T: e) m5 ]
功 能: 输出整数到硬件端口中 $ {$ m9 |2 M1 \0 W2 P5 S! Q
用 法: void outport(int port, int value); 9 x* Q& {! B! s- f
程序例: </P>
$ n4 t1 ~, j( r5 X5 N$ Y/ s8 t1 P1 k<><FONT color=#0000ff>#include <STDIO.H># C( j* S( d9 X" O8 ^2 @
#include <DOS.H>
( t6 f  V8 X0 B/ _  [# ]</FONT><FONT color=#0000ff>int main(void) + Z- ?, T) l. T1 h; |8 J
{
( J& ?' X0 K7 ^0 s3 _0 O" dint value = 64; ( s$ e+ T& s1 h! z
int port = 0; </FONT></P>6 _. r' X: k8 m4 ?9 a2 Q; m7 m  C' g
<><FONT color=#0000ff>outportb(port, value); 5 j7 m3 Z6 a2 q0 h( m/ L2 z
printf("Value %d sent to port number %d\n", value, port); 9 D  k- |0 @. @1 s9 g/ r, r2 N
return 0;
4 ]7 X6 p6 o2 u& a. m}
  G6 n6 J5 A( z( [" Z  i4 `8 d8 `</FONT>
/ ?3 K8 Z( ~" k1 S0 E$ ?</P>
3 k7 _: u7 ^. b1 |: Z4 }) \+ R<><FONT color=#ff0000>函数名: outportb </FONT>
4 R, k5 f+ G2 r功 能: 输出字节到硬件端口中 0 `& L5 V% _3 l3 [7 Y
用 法: void outportb(int port, char byte);
- p3 a: x2 t! V- ]3 I程序例: </P>
1 ?  U  h5 D7 [<><FONT color=#0000ff>#include <STDIO.H>
1 {  \9 O3 p* c( B/ O( d7 I2 G, C#include <DOS.H></FONT></P>
% k! i! J% j! K<><FONT color=#0000ff>int main(void)
2 u7 u( V1 r5 ?. X7 o! ^% Z{ / h1 P% b$ z3 j$ e4 j
int value = 64; & M0 u5 Q2 {% `9 x( r$ e
int port = 0; </FONT></P>
, |( `+ Y8 H5 F1 H0 w<><FONT color=#0000ff>outportb(port, value); ! Z( F: H: C7 N4 y5 G. M
printf("Value %d sent to port number %d\n", value, port);
" u  G/ K7 \/ Q( ]6 P9 D! H. kreturn 0; - ]- t, b8 t0 k5 j! g) X3 \* D7 l
} / B5 g6 a3 h& {- i
</FONT>
  `1 X: L5 R7 L! r1 r: `7 `! i7 E</P>
9 h* m# [7 J' {4 i# q- R<><FONT color=#ff0000>函数名: outtext </FONT>
: b. w9 X. u# G6 s- Y9 M功 能: 在视区显示一个字符串
& B2 \- E( C- n) K4 L5 T9 d5 h; Y用 法: void far outtext(char far *textstring);
4 R0 Y9 M- l: U& ?2 Y程序例: </P>
, [4 {1 D; s( _: ]0 P7 p<><FONT color=#0000ff>#include <GRAPHICS.H>1 }6 l3 K+ V1 @0 H
#include <STDLIB.H>
, m% C9 N3 `) u7 H  m3 i#include <STDIO.H>
$ _' F6 d3 @* x; ]2 x% O#include <CONIO.H></FONT></P>! Y5 Y/ O1 w) D, `: e9 l# e
<><FONT color=#0000ff>int main(void) . ~. o7 ^% q0 ~' l% F' e
{ 1 p: o( y, `& C6 s  N* i
/* request auto detection */ + M# {" C) a5 P! j' T
int gdriver = DETECT, gmode, errorcode; 9 s# ]  u& q/ _4 L
int midx, midy; </FONT></P>
: n7 x2 u( A' h) E0 ?2 |5 }<><FONT color=#0000ff>/* initialize graphics and local variables */ , X- U% @5 N7 X7 T7 m
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>. n0 ^4 ?3 ~$ {
<><FONT color=#0000ff>/* read result of initialization */
" R6 v2 T2 S- E9 p! h& r5 Verrorcode = graphresult(); ! @8 y! w- k- C- u; y3 ?
if (errorcode != grOk) /* an error occurred */ 5 x5 o! m8 K8 i8 A, \
{ 7 ]8 G; E, V. o1 j
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 3 _- _- h0 p% ~
printf("ress any key to halt:"); % P4 x' E! J! a) ~+ k2 m. Z
getch();
4 w6 _% r$ Y; L4 Eexit(1); /* terminate with an error code */ ; p9 J2 {! K& j2 ]  S% w9 W
} </FONT></P>
. ]- r' E2 N! D) g$ O3 X<><FONT color=#0000ff>midx = getmaxx() / 2;
- z6 R  G+ T3 m: M0 amidy = getmaxy() / 2; </FONT></P>5 k6 W% u3 g" _/ L
<><FONT color=#0000ff>/* move the C.P. to the center of the screen */ 8 h8 K: d0 E4 ^0 b( G# c
moveto(midx, midy); </FONT></P>
; Z' F* N. ?5 D* C  S<><FONT color=#0000ff>/* output text starting at the C.P. */ ; k' Z# x! P" n9 `; D( p4 x  R
outtext("This ");
( n8 a+ y2 `6 U& {: y9 [outtext("is ");
* _& k# Y. |- M! ]0 _outtext("a "); 0 ~' Z0 w; [) @$ o
outtext("test."); </FONT></P>
5 M# ^. y: {. f- n<><FONT color=#0000ff>/* clean up */ + s1 J$ D0 ?! V- K
getch(); 6 W' O& c( W4 R2 X7 h
closegraph();
2 t# S$ L7 ]0 {) `* D9 J4 @return 0;
5 _2 y2 \& i: p9 S- W. W* a' n} </FONT>
* [) F) s# L0 H. c( j- r) X4 A7 E  f8 h; n0 G
</P>. W; Q# y2 J7 v" T: s, l
<><FONT color=#ff0000>函数名: outtextxy</FONT> ! S$ ^3 v* V9 w  X! \
功 能: 在指定位置显示一字符串
$ E' S  }3 o9 f1 \; ?用 法: void far outtextxy(int x, int y, char *textstring); / h! C& z) s! n
程序例: </P># g  ]9 u2 S7 K: Y- Q( A
<><FONT color=#0000ff>#include <GRAPHICS.H>+ J2 T# r7 B& D' O9 J+ l: D
#include <STDLIB.H>% E1 C( M' m+ M5 d0 z" Z
#include <STDIO.H>
2 |' X' _/ U1 ?& a: ]6 d#include <CONIO.H></FONT></P>
4 u/ @) }" @1 [. {6 d0 M& u2 w<><FONT color=#0000ff>int main(void) 6 g0 u9 V- _3 M* |- U" v& t& }
{
" _5 Y7 i6 ^$ Q6 ^6 k/* request auto detection */
& O+ P; J2 Q5 n6 p9 C/ \( o; Kint gdriver = DETECT, gmode, errorcode; ) E9 J( `# x3 D
int midx, midy; </FONT></P>7 J+ x9 T" b! u4 D3 _$ c& ?% X
<><FONT color=#0000ff>/* initialize graphics and local variables */
3 @8 F  e- G* _: rinitgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>! x6 Z5 |" b6 U  c* ^
<><FONT color=#0000ff>/* read result of initialization */ 8 M8 X' J7 X; U# ]: ~  v/ [- S
errorcode = graphresult(); 0 b( N; m) e0 x6 L- I: {6 r
if (errorcode != grOk) /* an error occurred */
+ P6 R2 V: F. {7 H, \& K; L1 n{ " u% D, f+ C+ Y5 v& ?- E' H; u
printf("Graphics error: %s\n", grapherrormsg(errorcode));
1 i/ ^# ]  M2 q2 b+ H8 Vprintf("ress any key to halt:"); , i1 i8 b- |/ t- z2 P* E0 Z* S# o
getch();
/ q8 L- Y5 i+ j+ f: qexit(1); /* terminate with an error code */ * j" n# ~6 K. Q/ j9 N
} </FONT></P>( ]2 ]7 [1 t$ j+ x; [  J
<P><FONT color=#0000ff>midx = getmaxx() / 2;
0 d, P. A8 O( Q! V5 O& m7 Kmidy = getmaxy() / 2; </FONT></P>( Z/ v' ]: t& i  `2 h3 i. m
<P><FONT color=#0000ff>/* output text at the center of the screen*/ + q) n( b2 F" c+ I3 Y2 f8 j: x
/* Note: the C.P. doesn't get changed.*/ 9 L- T6 E, j6 D
outtextxy(midx, midy, "This is a test."); </FONT></P>4 s1 [. d6 x% ^) |- Z  }1 D! a' C
<P><FONT color=#0000ff>/* clean up */
& d) n/ Q. H1 p6 t1 j% Rgetch(); # u  K: Y" t( m  i3 ~, H9 C
closegraph(); / K" }" ]" k/ }+ |* a
return 0; / ^. t( q; Y* f9 w9 i
} </FONT></P>




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5