数学建模社区-数学中国

标题: 函数大全(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>6 `5 D5 V" @; ~
<><FONT color=#ff0000>void normvideo(void );
. i" @; X8 e- a. k1 m8 b5 r8 Y% l</FONT>选择正常亮度字符。
& [; z- E5 M( t0 ~( s将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
6 p' U4 T$ y( P. F* M# c- D6 `4 }+ k+ b! N1 s* [5 N& s
8 q& r7 T4 Q# u2 R6 G
<><FONT color=#ff0000>void nosound(void );. f4 k% |3 t3 X7 M* D, j+ I
</FONT>关闭由调用 sound而发声的扬声器。4 }6 B0 u- n& I7 @
</P>* E+ v+ }( z( B! ]
<><FONT color=#ff0000>函数名: open </FONT>
6 p8 X4 n! [0 w3 b9 d2 i功 能: 打开一个文件用于读或写
! A3 F( B6 r4 E: }% D0 R& _用 法: int open(char *pathname, int access[, int permiss]);
0 M6 w  t; @6 b5 h; |& w! ]5 t: _程序例: </P># Z3 _- H4 n: [0 B
<><FONT color=#0000ff>#include <STRING.H>0 t3 G2 }3 z# F
#include <STDIO.H>
1 ?7 @' A9 b% h0 d+ w9 {$ Z0 v+ F#include <FCNTL.H>
9 k7 B# A! q- E9 D#include <IO.H></FONT></P>
! @; b9 D* T: [<><FONT color=#0000ff>int main(void) 7 ?8 D' s& `# H3 J7 E' _9 E
{
0 u1 G+ Y2 C- O: K5 b% N2 Pint handle;   j/ d# W! c0 h+ B% H
char msg[] = "Hello world"; </FONT></P>
) s. g2 A/ |6 x( u( r<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
- X$ u( B3 M# e( r  l7 {% l{
# Z4 h  a- I* i  `& i9 e  j: sperror("Error:");
6 K: a5 o, M1 J0 yreturn 1;
: L# P1 G0 d" D. y% L5 n}
" b6 f) n7 Z7 P! w. }: ]* Owrite(handle, msg, strlen(msg));
; w* I" x9 Q- I) k  Zclose(handle);
* n5 w" z) o! y( ?0 Q5 |return 0; 0 N% h6 T7 l% l, `+ w4 B8 J
} ' [: _4 V* |$ a# t
</FONT>: [0 O2 T( _, n# h: d  p6 p
</P>
! ]* Z1 J8 p5 x2 E<><FONT color=#ff0000>函数名: outport </FONT>' x5 y- X+ V% ^: f0 \  K4 Q- k
功 能: 输出整数到硬件端口中 3 R3 u3 e# ~* p8 K- w6 }" s( t7 D
用 法: void outport(int port, int value);   B: N) S2 w9 e5 Y
程序例: </P># X6 S, w0 j; G9 u
<><FONT color=#0000ff>#include <STDIO.H>
$ w" p! ~7 x" z3 W9 s) j! @9 h#include <DOS.H>! c' o4 \' g5 O+ T* E+ T
</FONT><FONT color=#0000ff>int main(void) " q! S, @# P7 d. n
{
: B3 A0 g4 F( u; |& sint value = 64;
- m! G6 p2 @7 @/ c- Iint port = 0; </FONT></P>) C% X' t. d4 z
<><FONT color=#0000ff>outportb(port, value);
! @/ \' H0 N) S4 |7 n% oprintf("Value %d sent to port number %d\n", value, port);
0 B: L7 f: |$ H* Xreturn 0; / T  U8 L+ t: i6 n- d: b
} 8 o. ]- w) z. @+ m1 |  c
</FONT>: U: t& Q: R3 x& C
</P>
2 F7 d% w2 |' A8 x: A- i<><FONT color=#ff0000>函数名: outportb </FONT>  O/ {4 F: t9 Z- f
功 能: 输出字节到硬件端口中
& x& l) i3 g5 Z: F5 J用 法: void outportb(int port, char byte);
! P3 `  j- y4 ^" n9 [( |6 d程序例: </P>' c: ?; w( S5 }! R/ P! @) B) a
<><FONT color=#0000ff>#include <STDIO.H>
) f' ^1 `% G8 @/ ?#include <DOS.H></FONT></P>
, n, c# X3 X) ~<><FONT color=#0000ff>int main(void) & g! y8 w. m3 j4 g$ R$ b. B
{ ' U  w, B9 Z* {- p: A! _! _+ U
int value = 64;
+ @2 e) Y8 W; e. bint port = 0; </FONT></P>
7 d3 N! c" k0 d+ H& h<><FONT color=#0000ff>outportb(port, value); : Y2 i& m6 f/ S
printf("Value %d sent to port number %d\n", value, port);
" A6 n* v! L, w9 Mreturn 0;
0 L( `9 X( E& n# |4 G} ! T/ V- X) H2 ?/ ]
</FONT>
+ R( u# f; S* C1 d, b2 z3 g9 Z9 S</P>
* ~' R! y7 [) v5 @" J) U<><FONT color=#ff0000>函数名: outtext </FONT>
- Y, @; u6 R2 k  i功 能: 在视区显示一个字符串
: L' Y+ i4 |8 A4 r3 S, U# E用 法: void far outtext(char far *textstring);
- W' q( r. W6 `; r5 y" o* M& g2 m程序例: </P>
4 w8 A2 [" G) T; f- _' C* @1 ]<><FONT color=#0000ff>#include <GRAPHICS.H>
' H% Z+ E1 w* W: u4 z#include <STDLIB.H>
# k& W' s" O* y* ~! ^#include <STDIO.H>
$ t0 J# r# c9 O+ p% b#include <CONIO.H></FONT></P>
! j* A8 d& T6 w/ c% z$ y3 z<><FONT color=#0000ff>int main(void)
% a3 r8 s& g  z. d6 h3 ?4 k{
& W1 i, p* z0 @: y/* request auto detection */ * f% t; K+ \" F
int gdriver = DETECT, gmode, errorcode; ( n4 v, @( H! P  s
int midx, midy; </FONT></P>
, k: J& f6 P3 k( n! @2 v<><FONT color=#0000ff>/* initialize graphics and local variables */ 8 w- p! T) D/ M2 }+ x7 v6 D
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>+ j, r9 g& j) X
<><FONT color=#0000ff>/* read result of initialization */
$ n7 K+ Y. s2 r- M7 U7 E( Zerrorcode = graphresult();
) ~9 R, p# b: |: {1 W) @if (errorcode != grOk) /* an error occurred */ 4 v8 p( ~( y3 J: P% y0 ~8 c1 _6 j- [
{ / h& K6 Q$ Z# H$ t. H
printf("Graphics error: %s\n", grapherrormsg(errorcode));
( N, V: X$ O2 D& D6 Jprintf("ress any key to halt:"); ( w' z4 y5 N0 x) G& w0 l/ c$ {
getch(); / }  L" T$ F) D% y9 _2 V. g
exit(1); /* terminate with an error code */ 3 e! O" t7 |! W) G2 Q. I" m2 v" Y
} </FONT></P>
- \0 |2 ]" t8 z# j  M<><FONT color=#0000ff>midx = getmaxx() / 2;
! W) g# ~* T1 `midy = getmaxy() / 2; </FONT></P>+ S9 ?$ ~' E1 U" g0 O1 T0 _* a- z( \
<><FONT color=#0000ff>/* move the C.P. to the center of the screen */ 5 A2 I: T0 }+ S8 z4 l1 A6 M
moveto(midx, midy); </FONT></P># ]9 W* E% f3 L6 i7 N1 x
<><FONT color=#0000ff>/* output text starting at the C.P. */
9 i8 G- s, d! ]2 \2 louttext("This ");
% g! n- R% ?% K4 Couttext("is ");
- T3 [( v- o3 j( C, E- ?outtext("a ");
' E- Q: @# q( e# `8 [( R/ x: zouttext("test."); </FONT></P>
; A+ c* I* L0 G! h1 d: r% b" e3 }<><FONT color=#0000ff>/* clean up */
- r3 ~7 t2 J( a2 V; ?% `getch();
- V7 m% U# v( `: A% g% ~8 oclosegraph(); $ c4 J9 ?- l3 j4 K; [% c
return 0;
3 N! o: I' q! X  h- e} </FONT>
) C* p" `7 j* o, l
, D, i/ i+ b4 a5 E6 k1 P2 H</P>' H: x. x. h2 z5 A" O1 p
<><FONT color=#ff0000>函数名: outtextxy</FONT>
; h" ~: E0 i0 \$ z$ @功 能: 在指定位置显示一字符串
, L. Z3 |) h0 h) W6 X用 法: void far outtextxy(int x, int y, char *textstring);
3 e/ u( U$ q8 V8 a5 r2 i程序例: </P>  x: P# ?  B! A8 f  s5 L- m) P
<><FONT color=#0000ff>#include <GRAPHICS.H>
: ~) L9 Z/ a4 ?$ R' t" l5 G1 z* ]#include <STDLIB.H>
) L! A4 h6 _7 H( [4 ^1 Z. d' _4 @+ u" @#include <STDIO.H>
6 O' R" A1 @, E# ^% d#include <CONIO.H></FONT></P>% ^7 X" a# @( Q: J' a7 N; N
<><FONT color=#0000ff>int main(void) & L6 [0 ]* }  R' m" E
{ + d# L. i8 h  r& [* t
/* request auto detection */
9 z* p) Z- z$ `int gdriver = DETECT, gmode, errorcode; ; [* `; k; |0 G# e3 ]4 ]" d' g" `: d
int midx, midy; </FONT></P># {$ e8 n, G4 V6 s# w1 L1 @' X
<><FONT color=#0000ff>/* initialize graphics and local variables */
) G8 V4 J7 X" xinitgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>8 m2 t/ ~. F/ W  y8 ?- c
<><FONT color=#0000ff>/* read result of initialization */ ' P* r9 Y5 {3 F/ n% I( B4 o3 d
errorcode = graphresult();
* L9 \$ p' p  i) @8 ]' g2 Iif (errorcode != grOk) /* an error occurred */
# z; [" D) F- ^# E4 Q{
- D/ j, h% D5 ?4 o5 ^- M, J& A+ f) [printf("Graphics error: %s\n", grapherrormsg(errorcode));
. Z5 K* ^" u- ?# yprintf("ress any key to halt:");
; K" T% L6 |( Agetch(); 7 v1 u7 K% J! S# q1 C  g0 I
exit(1); /* terminate with an error code */
( Z4 x$ i) U- R) m0 W  Q} </FONT></P>6 r& w# c4 H4 L8 v
<P><FONT color=#0000ff>midx = getmaxx() / 2; ) _* w: H' C: P% y
midy = getmaxy() / 2; </FONT></P>
! L0 X; |8 h2 N' _. r! D<P><FONT color=#0000ff>/* output text at the center of the screen*/ ; w8 ?, x/ ~  }6 ?3 \2 J
/* Note: the C.P. doesn't get changed.*/ / W  F* C% z! l8 C7 Z3 B
outtextxy(midx, midy, "This is a test."); </FONT></P>
  q3 S- j, S/ Q<P><FONT color=#0000ff>/* clean up */
" M* e  e6 U: T) q' x1 Kgetch();
( Q6 P* _& n8 D. y* ^closegraph();
. r$ q9 h4 ?7 U2 Greturn 0;
0 b' E* Z" {1 l. l& D" m} </FONT></P>




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