数学建模社区-数学中国

标题: 函数大全(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>! A6 g/ {( f) k
<><FONT color=#ff0000>void normvideo(void );
$ F. k  T. C! p2 e4 k% L/ H% G* @</FONT>选择正常亮度字符。
7 V% M8 P  K4 Z- J3 `5 P将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>, J" z; ]" G& }4 r

+ m% r+ d) \5 s  \  }
, B5 f6 t6 _1 `/ e: O) Q9 T* ]+ s<><FONT color=#ff0000>void nosound(void );
: u9 P* P" ~" K! l6 }4 e</FONT>关闭由调用 sound而发声的扬声器。; K7 P/ L& b: S. Z2 x0 t- y
</P>
5 {& k: y+ r! p<><FONT color=#ff0000>函数名: open </FONT>
! M4 d/ ~" ]3 I9 o/ o% M功 能: 打开一个文件用于读或写 . ~# B0 I- S, f6 G
用 法: int open(char *pathname, int access[, int permiss]);
; m+ z4 B" n- W& G4 r; ~程序例: </P>
, b! h7 U" u. a% U<><FONT color=#0000ff>#include <STRING.H>
; r8 k  P. u5 ]5 \4 R#include <STDIO.H>: ]/ e9 m$ i; T' ^# Z
#include <FCNTL.H>( O4 J& z5 X' ^
#include <IO.H></FONT></P>. t5 N' J3 |0 S: a9 @+ n9 c( s$ d
<><FONT color=#0000ff>int main(void)
% \& u" v2 E  [* F$ R# B  W{ * _" M) ~. r5 a' j5 [$ W3 `$ e
int handle;
% A2 K5 t% A- W% G2 b& k) ~char msg[] = "Hello world"; </FONT></P>
  F0 _+ L0 g+ X& w) G+ O1 P' @0 o<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) 2 S# n) ^4 V" ?) e) P
{ ! s# B$ a6 }/ ]0 q
perror("Error:");
* F0 G% {- j1 @return 1;
" O3 C. |# I4 r9 E* A1 C}
( f- ?% w- x* k# f2 }4 }. Ewrite(handle, msg, strlen(msg)); * a: G$ v* J1 l1 |, ~
close(handle);
3 t& N5 v2 ^( {) D/ `( Jreturn 0; & r- ^! R, o/ L8 p" T
}
6 i; n$ b6 I6 v+ o</FONT>
5 R7 k! C; a+ U</P>
' n' |- V( g% M4 u' z, G; `<><FONT color=#ff0000>函数名: outport </FONT>
8 T1 q4 t+ Y/ U% P功 能: 输出整数到硬件端口中 7 I4 x. `$ H, U& K* P8 Y# C
用 法: void outport(int port, int value); ; B1 X7 w$ m+ E+ i
程序例: </P>
5 t( a* F, I/ Z' K<><FONT color=#0000ff>#include <STDIO.H>/ H, e: [/ V0 `
#include <DOS.H>4 ~( d( Y- w1 `; Z
</FONT><FONT color=#0000ff>int main(void) ; e0 U3 w; x( `9 ^4 ?$ d+ D& O
{ 3 k, A. |0 _, [, R0 {2 T
int value = 64; 3 A. i: `" u5 ]1 L' R* w% {
int port = 0; </FONT></P>
9 w# d# W7 _& a( Q3 U2 @* I3 P<><FONT color=#0000ff>outportb(port, value); 5 V. q( m* F4 Z+ R* i5 ]. @' ]3 F0 ]
printf("Value %d sent to port number %d\n", value, port);
2 U! \* B) o8 `& dreturn 0;
6 P9 V) d' t" O! F  _} % i* i* i7 w% g3 q
</FONT>
; b% V1 Y1 W3 E& [1 b' a</P>0 j; t+ Y# m- ]  n( I. X: ?
<><FONT color=#ff0000>函数名: outportb </FONT>
" \0 |" j0 C: c0 X: Q9 R功 能: 输出字节到硬件端口中 , l9 ~2 N; ~+ W" G/ Y
用 法: void outportb(int port, char byte); & g# E+ N. ~) u+ Y7 j9 Q
程序例: </P>
; a( E5 B' d. X<><FONT color=#0000ff>#include <STDIO.H>! D" O% Z$ J) C9 n7 W, [. B
#include <DOS.H></FONT></P>
' J) v$ \) Q5 C% l3 F8 r<><FONT color=#0000ff>int main(void)
; I1 l# u  v+ j( B' y{
( U# n# N/ G- Q3 m  |5 D% mint value = 64; 4 j' Q4 Y/ ?# M. u  m' _, w
int port = 0; </FONT></P>8 W6 m! y3 o4 h  F
<><FONT color=#0000ff>outportb(port, value);
' T7 n; h* H- ~9 E, S" L; e' s  kprintf("Value %d sent to port number %d\n", value, port);
4 h; P- w# s# R0 b$ h2 W9 P! S9 breturn 0;
0 z; Q* w. C5 R% @} * K; V+ z: v& Z' X
</FONT>' u4 ]( ]' A$ G4 ^( n
</P>; j5 G) z/ X  ?8 K0 h
<><FONT color=#ff0000>函数名: outtext </FONT>$ T1 S! S6 T6 r! K
功 能: 在视区显示一个字符串 # k7 w) r" R6 ]" V, X: `
用 法: void far outtext(char far *textstring);
# L! N$ a( [8 j6 _1 E; X程序例: </P>1 r, g3 l$ V$ B7 m/ D8 u3 F6 M0 n
<><FONT color=#0000ff>#include <GRAPHICS.H>
1 M" v" C8 J: k$ l! H#include <STDLIB.H>
& f2 J! M# [0 Y" z#include <STDIO.H>
2 l  y! r; [, z: n& ^5 Q2 R#include <CONIO.H></FONT></P>: x$ }  k6 w+ q* a/ o5 @
<><FONT color=#0000ff>int main(void)
) i$ d5 C7 n' G  L{
8 T) N8 R! S, w7 f" _/* request auto detection */
$ W3 L* j8 u* J" n8 gint gdriver = DETECT, gmode, errorcode;
7 N' u% c9 z9 @2 Yint midx, midy; </FONT></P>- O2 C" R  i2 ^& n, T$ p, d, T
<><FONT color=#0000ff>/* initialize graphics and local variables */ + e$ J3 b4 P! z4 t: c" T; C4 s& |) M
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>4 R) ~0 N  {' P1 w
<><FONT color=#0000ff>/* read result of initialization */ 7 b1 l. V9 m6 V1 p
errorcode = graphresult(); % w, [- E/ b) V6 c+ l
if (errorcode != grOk) /* an error occurred */
# J  L0 P" g0 u+ S{ ' L4 _4 n4 \# D& _3 k
printf("Graphics error: %s\n", grapherrormsg(errorcode));
; w6 Z/ w+ f1 L/ c" w' @printf("ress any key to halt:"); # F) _" K, G( J4 c( M+ y! a
getch(); 9 @' Y9 A* l1 I% t3 X; C
exit(1); /* terminate with an error code */ $ `2 u3 u) L- K' |
} </FONT></P>6 E* L% K! e- c7 U5 Z' U: g% s
<><FONT color=#0000ff>midx = getmaxx() / 2; - P5 ~/ ^' f5 A2 {4 |
midy = getmaxy() / 2; </FONT></P>3 `8 a+ X7 I/ u4 Q* I$ }
<><FONT color=#0000ff>/* move the C.P. to the center of the screen */
: T' \$ e9 d0 h7 O/ Dmoveto(midx, midy); </FONT></P>
- I! O/ J! {9 A* `+ i# k# c/ v<><FONT color=#0000ff>/* output text starting at the C.P. */
' P& x) l7 l( d( R; I. Touttext("This ");
% n$ W6 r/ |  t) {, k: v& y/ b) touttext("is "); - I! E  M0 `; G: _
outtext("a "); 7 O' r4 O1 R' s( f$ H6 V( P8 g' U
outtext("test."); </FONT></P>6 q3 z" F2 s# j4 [/ G
<><FONT color=#0000ff>/* clean up */
, J6 L. S* Y! N2 O/ h: Igetch();
7 Q: S: m6 ]- K* d7 j/ }3 ^- p: `closegraph();
% i) o2 A6 c8 a' [return 0; ! q/ t3 \3 T. D. a8 \
} </FONT>
+ l  z8 _' \$ C8 Z# f9 ~4 w5 H8 y; \# q; ]7 I! g+ x: j
</P>
5 h6 \6 b* ]1 h5 r<><FONT color=#ff0000>函数名: outtextxy</FONT>
8 i  @! C% z- c# @9 N功 能: 在指定位置显示一字符串 $ L" P8 t! h2 s8 E7 o
用 法: void far outtextxy(int x, int y, char *textstring); 2 Z0 F& N, b7 E, y9 Z
程序例: </P>
4 c- D4 f) m7 o<><FONT color=#0000ff>#include <GRAPHICS.H>
& q# V) D7 J& z5 O$ R" f6 n# U#include <STDLIB.H>+ ~3 J2 Z1 l. }, _
#include <STDIO.H>
  v1 a% y& n4 V- d) G' _#include <CONIO.H></FONT></P>
& U  T0 L( L0 M' D' A0 ]1 X' ~<><FONT color=#0000ff>int main(void) 2 |5 ^- g2 y* q6 t0 ~& {, t; u5 K
{
1 g  L; M1 Z) p/* request auto detection */
/ Z3 t% G+ b( Y. ~4 _0 O8 m% Jint gdriver = DETECT, gmode, errorcode; % e$ v# C8 G% ~. ?; v! k
int midx, midy; </FONT></P>2 H6 l/ T4 F, t& U, @
<><FONT color=#0000ff>/* initialize graphics and local variables */ $ w9 j& @# [$ }* t( F. G
initgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>1 E9 G) q- X' n- X
<><FONT color=#0000ff>/* read result of initialization */
4 I" ^* {3 \! `( Verrorcode = graphresult();
0 u  p2 p# \- j8 Jif (errorcode != grOk) /* an error occurred */ * Z+ i& ~" l& K7 W# Z& H: Y
{
, m' [5 s3 f- V; ^% fprintf("Graphics error: %s\n", grapherrormsg(errorcode)); / q4 V1 N* Y4 |1 Z5 c
printf("ress any key to halt:");
' X1 n0 u2 w8 r! `: ?% `9 ggetch();
8 C+ H+ j* x- O* @9 m0 Fexit(1); /* terminate with an error code */
/ H; a  p& @: y! q} </FONT></P>* r2 A5 M, b+ }4 e6 S- F
<P><FONT color=#0000ff>midx = getmaxx() / 2; . B, u  P6 W, S( |# w
midy = getmaxy() / 2; </FONT></P>
! }! e* v9 U1 m) C/ r6 ^<P><FONT color=#0000ff>/* output text at the center of the screen*/
9 ?. ~6 y$ m, M1 A; q) B" p/* Note: the C.P. doesn't get changed.*/ 9 x0 M7 f7 ~! g- P% [6 u# q) B
outtextxy(midx, midy, "This is a test."); </FONT></P>
' b" f. A. v/ B. ?3 K  ?5 \) L% n: P<P><FONT color=#0000ff>/* clean up */
+ |1 g! J" b$ X( t+ [: Igetch(); " V2 \$ e; z- {( }- {
closegraph(); 4 ^* |) h) e6 d& y2 _0 i
return 0; ' H( B9 o0 y2 W- l: {, S: z- _
} </FONT></P>




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