数学建模社区-数学中国

标题: 函数大全(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>
7 E4 B6 ]2 m. V; n. F<><FONT color=#ff0000>void normvideo(void );1 d" F6 c6 f1 C) p' V9 b
</FONT>选择正常亮度字符。' O2 Z# w* {2 \/ b$ l% G7 Q
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>% O& K$ n0 p3 c- \9 Y: W

" }8 y0 C* @- I5 c; @
! |0 {8 A4 _$ T0 G. F3 m# x<><FONT color=#ff0000>void nosound(void );: ?$ N  V8 t1 _' h+ q
</FONT>关闭由调用 sound而发声的扬声器。
! `/ x6 h: J6 D' x4 C- F# {, ]( y6 [</P>- h& w9 m! c% v% U- h
<><FONT color=#ff0000>函数名: open </FONT>
: K: y& V0 D; D$ i" m功 能: 打开一个文件用于读或写 9 ]& O2 J8 i4 b; Y" S$ K  K
用 法: int open(char *pathname, int access[, int permiss]); & r1 R. j8 d- A
程序例: </P>3 v4 F8 q. g6 H' V7 |
<><FONT color=#0000ff>#include <STRING.H>
- y, s! V$ w+ b5 W9 R5 f3 p/ r#include <STDIO.H># s5 D+ }* t" H) B8 `! r5 g. a
#include <FCNTL.H>
- s' n* p/ m# N$ W0 c. n#include <IO.H></FONT></P>0 d0 r* [: B! S% P
<><FONT color=#0000ff>int main(void)
/ s3 Q: R& R9 y{ . P0 D7 Z5 W4 n, l& Q
int handle;
* C& _7 @7 S, ~( Z# tchar msg[] = "Hello world"; </FONT></P>
! H- t4 G* S8 s" Q<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
9 Y: s9 i) l4 c) O3 d7 S1 s! R{ & P9 B5 M7 K' G# C8 h8 L: D" Q
perror("Error:"); ' j! Q+ Q2 \& v( B
return 1; / k! a* V2 n7 c! S( C$ t
}
. \& v3 P1 l. q9 fwrite(handle, msg, strlen(msg));
( T3 C  o4 r& E" x1 L: Tclose(handle);
0 I3 k! E+ ^) Freturn 0; ) r( \5 y  U( k5 h, |' P
} 9 I7 b; Y5 k; t/ e) L
</FONT>
( z+ B- D# G" q: d0 E</P>( U4 I1 `' Q& z. X. b$ K
<><FONT color=#ff0000>函数名: outport </FONT>
" q- W8 L8 ^9 z8 n/ L功 能: 输出整数到硬件端口中
" c- d* s6 q" M# I  p7 E用 法: void outport(int port, int value);
7 w9 |  f! O3 b% I' v4 o程序例: </P>* d) r& d4 ~0 T; T6 N9 O
<><FONT color=#0000ff>#include <STDIO.H>
7 c' @0 }* @' o6 `#include <DOS.H>( O4 {- ^$ Z  x; ]; y8 c
</FONT><FONT color=#0000ff>int main(void)
* f/ P) W& J3 A; y* g{ ; k2 W" q; k6 f* E7 D7 M
int value = 64;
: r2 w6 Q/ }# F9 Fint port = 0; </FONT></P>6 L9 z- {$ O, X4 ~7 J( X' f
<><FONT color=#0000ff>outportb(port, value);
9 n# c7 b  j) d! I8 T0 \printf("Value %d sent to port number %d\n", value, port);
: d& f$ D) E9 Rreturn 0;
7 F2 m& F6 K  k' A1 g6 u}
3 S& j/ d! m2 f; ~4 X( e% H, {6 d</FONT>
% H8 R1 ]$ _! ^* @7 l+ O</P>" `0 v5 F* a7 a, D7 X9 m' N
<><FONT color=#ff0000>函数名: outportb </FONT>
4 k' _- G$ R! @% ~4 q1 b, h功 能: 输出字节到硬件端口中
2 i5 u- t" s4 T/ b用 法: void outportb(int port, char byte);
2 E7 V. a- k6 p/ W* S3 x程序例: </P>
- N# q( k# ~  Y0 k( v<><FONT color=#0000ff>#include <STDIO.H>
8 Q7 l; f6 g8 t" J#include <DOS.H></FONT></P>* t8 N1 A. g/ V1 }3 z" m& F. x
<><FONT color=#0000ff>int main(void) 8 c' b1 H6 Q# U/ [' C" B1 z/ r6 [
{ # g  R2 k, z0 z) d% v+ o8 h+ Z
int value = 64;
* k0 I% z  ~( A5 N# Y0 }int port = 0; </FONT></P>
$ Z8 c; ]; f* `6 `0 _4 O- `<><FONT color=#0000ff>outportb(port, value);
/ y* N& c+ {0 z! w( d" Z4 L! g, Lprintf("Value %d sent to port number %d\n", value, port); / g- b/ [% V2 r# S- l
return 0;
2 }1 P) c* S5 @5 z4 ^: H} " U. }* Z1 l9 e- ^  k  F2 F  F  I
</FONT>
$ H$ s2 V* G+ b4 r6 Q</P>+ i3 _9 j( N1 P: H6 R' L
<><FONT color=#ff0000>函数名: outtext </FONT>8 P" z* t4 `1 k& v8 a
功 能: 在视区显示一个字符串
; l2 U5 i0 p4 C: _# c' L用 法: void far outtext(char far *textstring);
" y2 z: F" ~& i7 G4 B) s* ?程序例: </P>5 M" E. e5 Q( ~" Y9 j  U
<><FONT color=#0000ff>#include <GRAPHICS.H>5 e. U  k. t1 t# Y: g/ q
#include <STDLIB.H>
% t$ Z' p6 N$ k4 A5 E3 G; e  f#include <STDIO.H>/ j) R; [2 c$ v, _% Z5 q, Y
#include <CONIO.H></FONT></P>
7 ~  l& k/ K6 X% S0 q- j# e9 k<><FONT color=#0000ff>int main(void) / W! H  w+ a; M; L& J& }5 |
{
# R) @( g2 g- r" T6 S9 B) z/* request auto detection */
* X% D/ M& @  m# pint gdriver = DETECT, gmode, errorcode;
" C" |& _2 C$ w6 V6 G( ~int midx, midy; </FONT></P>
% L; Y. T' C' v<><FONT color=#0000ff>/* initialize graphics and local variables */
5 _8 o7 Z# P' z$ M! Z+ ^# Q! uinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
8 V+ S+ e! m/ o1 V  B0 T<><FONT color=#0000ff>/* read result of initialization */
- p" @' u5 `) F3 O0 ~errorcode = graphresult();
( o& z1 _$ }' ?' _( \if (errorcode != grOk) /* an error occurred */ 5 N' h/ y7 m& I* r
{
+ f- a7 E6 O3 I  _, @. Z7 n. Bprintf("Graphics error: %s\n", grapherrormsg(errorcode));
+ p3 u& S: y/ y1 W6 \. Lprintf("ress any key to halt:"); ( m) E8 _4 U: g2 m4 \
getch(); ' N+ C( q0 g) x* x
exit(1); /* terminate with an error code */
" r" E7 N& l3 l+ z0 B} </FONT></P>
" u& w3 \+ T  d1 ]6 T<><FONT color=#0000ff>midx = getmaxx() / 2;
8 L+ P* X7 |: D5 |midy = getmaxy() / 2; </FONT></P>+ s; g; M5 g  a' ]" f
<><FONT color=#0000ff>/* move the C.P. to the center of the screen */
( S2 a6 a3 m1 R: wmoveto(midx, midy); </FONT></P>
! i5 }1 S$ {; D% Y6 M<><FONT color=#0000ff>/* output text starting at the C.P. */ / W! s- ?1 f6 H8 ]# }) F
outtext("This ");
+ D; l% }* ]6 L+ x( _) Z& Jouttext("is "); 5 E0 Q8 z; T8 J* ?& ?/ _
outtext("a "); + f  R1 \( q+ v5 e# a( {
outtext("test."); </FONT></P>
( R) E4 u8 I0 P, Y& ~* J4 N<><FONT color=#0000ff>/* clean up */ / ]" q- U$ g0 _/ }) n
getch();
- J2 c- e" _8 r  F" |) g) Zclosegraph(); ! e- N2 O$ }$ P
return 0; % Z3 G5 v. T7 k7 y8 u
} </FONT>
; a% o: T0 Y- _; e; {6 }" N5 z: c# Y. `8 _* @
</P>2 Y4 R* b. c) x/ r0 h% n% N$ G9 S
<><FONT color=#ff0000>函数名: outtextxy</FONT>
2 g- E; B3 J. X2 \6 K+ t0 b: P功 能: 在指定位置显示一字符串
5 G. G# U& Q2 k. X: I  L用 法: void far outtextxy(int x, int y, char *textstring);
  s9 T- ~! a: H程序例: </P>
/ o8 F$ @! ~# f/ Q, R" P5 S- G<><FONT color=#0000ff>#include <GRAPHICS.H>
0 }  v. o( p( [#include <STDLIB.H>
/ w! W+ x( b8 v( p#include <STDIO.H>0 H, S9 X* \" z  g& M
#include <CONIO.H></FONT></P>
3 H; B# {% K; I* d<><FONT color=#0000ff>int main(void) " w! q. s$ {( Y
{
/ s2 d; ^( ^0 W! D- P+ P! l/* request auto detection */ - E, a  H1 g* q, Q. g
int gdriver = DETECT, gmode, errorcode;
- }6 f8 f9 {3 Z" ~; @) Cint midx, midy; </FONT></P>
+ a0 _, m5 G+ T' w& Q, J<><FONT color=#0000ff>/* initialize graphics and local variables */
* K, P+ c1 `2 ninitgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>
# u) q5 X) f& Z+ X& f& ?" U<><FONT color=#0000ff>/* read result of initialization */
2 k$ C8 @: r' n2 h5 lerrorcode = graphresult();
3 X% e( `8 P9 w4 U- Z& cif (errorcode != grOk) /* an error occurred */
& A, J- f. q) j5 H( ]{ % [+ X$ G, H# \( i3 Y
printf("Graphics error: %s\n", grapherrormsg(errorcode)); ( \& G5 u( ?( ]
printf("ress any key to halt:"); ' A( H- E' a* m
getch(); 3 I! s' Z# ~  ]# F1 h* w+ e
exit(1); /* terminate with an error code */
6 S1 T, {/ b- r6 `3 S& r5 h" Z} </FONT></P>
- I( a* H  b9 F4 B) }( y<P><FONT color=#0000ff>midx = getmaxx() / 2; 3 m9 @/ B) J+ U; ^- E1 g1 }
midy = getmaxy() / 2; </FONT></P>
" f* p, \4 {% f0 r. j* c# [<P><FONT color=#0000ff>/* output text at the center of the screen*/ ! b4 P" i! A$ }3 Q
/* Note: the C.P. doesn't get changed.*/
0 Y1 r8 g8 c) @outtextxy(midx, midy, "This is a test."); </FONT></P>
, t1 V" b% e; x9 j4 x+ Y<P><FONT color=#0000ff>/* clean up */
3 T/ h2 m$ R2 u# p# O1 ^4 zgetch(); 6 u/ q& q0 e, b
closegraph();
0 @% _$ x/ g2 c5 b* k, Treturn 0; + U0 F8 l- @4 w
} </FONT></P>




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