『壹』 求c語言的常用函數,詳細一點
C語言的常用庫函數
函數1。absread()讀磁碟絕對扇區函數
函數2。abswrite()寫磁碟絕對扇區函數
函數3。atof()將字元串轉換成浮點數的函數
函數4。atoi()將字元串轉換成整型數的函數
函數5。atol()將字元串轉換成長整型數的函數
函數6。bcd()把一個數轉換成對應的BCD碼的函數
函數7。bdos()
函數8。biosdisk()調用BIOS磁碟驅動程序函數
函數9。biosprint()調用BIOS列印機I/O介面的函數
函數10。calloc()分配內存函數
函數11。ceil()
函數12。cgets()讀字元串函數
函數13。chdir()改變當前目錄的函數
函數14。_chmod()改變文件存取許可權的函數
函數15。chmod()改變文件存取許可權的函數
函數16。clock()
函數17。close()關閉文件函數
函數18。closegraph()關閉圖形函數
函數19。cos()
函數20。ctrlbrk()設置ctrl-break處理程序的函數
函數21。delay()暫停函數
函數22。disable()屏蔽中斷的宏
函數23。enable()開硬體中斷的宏
函數24。exec()載入並運行其它程序的函數族
函數25。farcalloc()從遠堆中分配內存的函數
函數26。farfree()從遠堆中釋放一塊已分配內存的函數
函數27。farmalloc()從遠堆中分配內存的函數
函數28。farrealloc()調整遠堆中已分配塊的函數
函數29。fclose()關閉一個流函數
函數30。fcloseall()關閉打開的流的函數
函數31。feof()檢查文件是否結束的函數
函數32。fgets()從流中讀取一字元串的函數
函數33。findfirst()函數和findnext()函數
函數34。floodfill()填充區域的函數
函數35。floor()
函數36。fnmerge()建立文件路徑函數
函數37。fnsplit()分解完整的路徑名函數
函數38。fopen()打開一個流函數
函數39。FP_OFF()獲取遠地址偏移量的宏
函數40。fprintf()傳送輸出到一個流中的函數
函數41。FP_SEG()獲取遠地址段值的宏
函數42。fscanf()格式化輸入函數
函數43。fseek()移動文件指針函數
函數44。fwrite()把參數寫入流中的函數
函數45。gcvt()把雙精度數轉化成字元串的函數
函數46。geninterrupt()執行中斷函數
函數47。getc()從流中取字元的宏
函數48。getch()從鍵盤無回顯地讀取一字元的函數
函數49。getchar()從stdin流中讀取一個字元的函數
函數50。getcurdir()讀取指定驅動器的當前目錄的函數
函數61。getcwd()讀取當前目錄的函數
函數62。getdate()讀取系統日期函數
函數63。getdfree()讀取磁碟空閑空間的函數
函數64。getdisk()讀取當前磁碟驅動器號函數
函數65。getenv()讀取環境變數的當前值的函數
函數66。getimage()將指定區域的點陣圖象存入內存的函數
函數67。getmaxx()返回屏幕上最大的X坐標值的函數
函數68。getmaxy()返回屏幕上最大的Y坐標值的函數
函數69。getpixel()讀取像素顏色的函數
函數70。getpsp()
函數71。gets()從標准輸入流stdio中讀取一字元串的函數
函數72。gettime()讀取系統時間的函數
函數73。getvect()讀取中斷向量函數
函數74。getx()返回當前圖形方式下位置的X坐標值的函數
函數75。gety()返回當前圖形方式下位置的Y坐標值的函數
函數76。imagesize()返回保存圖像緩沖區大小的函數
函數77。initgraph()顯示模式控制函數(初始化圖形系統函數)
函數78。inport()從埠中讀入一個字的函數
函數79。inportb()從埠讀入一個位元組的函數
函數80。int86()執行中斷函數(調用8086軟中斷函數)
函數81。int86x()執行中斷函數 (通用8086軟中斷介面函數)
函數82。intdos()通用dos中斷介面函數
函數83。intdosx()通用dos中斷介面函數
函數84。intr()執行8086軟中斷函數(改變軟中斷介面函數)
函數85。itoa()把整形數轉換為字元串的函數
函數86。kbhit()檢查當前按下的鍵的函數
函數87。keep()駐留並退出函數
函數88。log()
函數89。log10()
函數90。_lrotl()將一個無符號長整形數左循環移位的函數
函數91。_lrotr()將一個無符號長整形數右循環移位的函數
函數92。lseek()移動文件指針函數
函數93。ltoa()把長整形數轉換為字元串的函數
函數94。malloc()分配內存函數
函數95。mkdir()創建目錄函數
函數96。mktemp()建立一個唯一的文件名的函數
函數97。MK_FP()設置一個遠指針的宏
函數98。movedata()拷貝數據函數
函數99。_open()打開一個文件進行讀寫的函數
函數100。open()打開文件進行讀寫的函數
函數101。outport()輸出一個字到埠中的函數
函數102。outportb()輸出一個位元組到埠中的函數
函數103。outtextxy()在指定位置顯示一字元串的函數
函數104。peek()返回指定內存中字的函數
函數105。peekb()返回指定內存中位元組的函數
函數106。poke()在指定的內存中存儲一個字的函數
函數107。pokeb()在指定的內存中存儲一個位元組的函數
函數108。pow()
函數109。printf()寫格式化輸出到stdout的函數
函數110。putch()向屏幕輸出字元的函數
函數111。putchar()在stdout上輸出字元的宏
函數112。putenv()將字元串放入當前環境中的函數
函數113。putimage()重新寫屏函數(輸出一個點陣圖象到圖形屏幕上的函數)
函數114。putpixel()寫像素點函數
函數115。puts()輸出一字元串到stdout(標准輸出)的函數
函數116。_read()讀文件函數
函數117。read()讀文件函數
函數118。realloc()重新分配內存函數
函數119。rectangle()畫一個矩形的函數
函數120。remove()刪除一個文件的函數
函數121。rename()文件改名函數
函數122。restorecrtmode()恢復屏幕視頻模式為調用initgraph前的設置的函數
函數123。rmdir()刪除目錄函數
函數124。_rotl()將一個無符號整形數左循環移位的函數
函數125。_rotr()將一個無符號整形數右循環移位的函數
函數126。scanf()格式化輸入函數
函數127。searchpath()按dos路徑查找一個文件的函數
函數128。segread()讀段寄存器函數
函數129。setactivepage()設置圖形輸出活動頁的函數
函數130。setcolor()設置當前要畫的線顏色的函數
函數131。setdisk()設置當前驅動器的函數
函數132。setgraphmode()將系統設置成圖形模式並清屏的函數
函數133。setlinestyle()設置當前畫線寬度和類型的函數
函數134。settextstyle()顯示字元的當前設置函數
函數135。setvect()設置中斷向量函數
函數136。setviewport()建立視口的函數
函數137。setvisualpage()設置可見的圖形頁號的函數
函數138。sin()
函數139。sprintf()格式化輸出到數組的函數
函數140。strcat()
函數141。tan()
函數142。_write()寫文件函數
函數143。write()寫文件函數
原文釋義請到網路文庫里搜尋字串「C語言常用函數」後下載
函數51-60因原注里排序號碼少編,所以只有133個常用函數。
DOC大小是119.5KB
貢獻時間:2010-09-10
貢獻者:handanlinzhang
『貳』 求純C語言打字游戲源代碼及解析
# include "Typer.h"
# include <stdio.h>
# include <stdlib.h>
# include <graphics.h>
//download by http://www.codefans.net
void main()
{
BOOL bQuit=FALSE; /* 是否退出 */
BOOL bPause=FALSE; /* 是否暫停 */
int tm1,tm2;
BYTE Key;
randomize(); /* 初始化隨機數種子 */
SetGraphMode();
SelectLevel();
ShowBar();
tm1=CreateTimer(1,MoveLetter); /* 創建移動字元對象時鍾 */
tm2=CreateTimer(Interval,CreateLetter); /* 創建產生字元對象時鍾 */
CreateLetter();
Key=AscKey();
while (!bQuit)
{
TimerEvent();
switch (Key)
{
case NULL:
break;
case KEY_ESC:
bQuit=TRUE;
break;
case KEY_SPACE:
bPause=!bPause;
tmTM[tm1].Enable=!bPause;
tmTM[tm2].Enable=!bPause;
break;
default:
if (!bPause) Check(Key);
}
Key=AscKey();
}
CloseGraphMode();
}
void SetGraphMode()
{
int Device=VGA,Mode=VGAHI;
initgraph(&Device,&Mode,"");
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
setfillstyle(SOLID_FILL,0);
setcolor(7);
}
void CloseGraphMode()
{
restorecrtmode();
}
/* 從鍵盤緩沖區內直接讀出ASC碼 */
BYTE AscKey(void)
{
int start,end;
WORD key=0;
start=peek(0,0x41a);
end=peek(0,0x41c);
if (start==end) return(0);
else
{
key=peek(0x40,start);
start+=2;
if (start==0x3e) start=0x1e;
poke(0x40,0x1a,start);
return(key&0xff);
}
}
void MoveLetter(void)
{
int i;
for (i=0;i<MAX_LETTER;i++)
{
if (Letter[i].Used)
{
HideLetter(i);
Letter[i].y+=Step;
ShowLetter(i);
/* 字元對象下落到最底部 */
if (Letter[i].y>MAX_HEIGHT) KillLetter(i);
}
}
}
void KillLetter(int LetterID)
{
if (Letter[LetterID].Used)
{
Letter[LetterID].Used=FALSE;
LetterUsed--;
HideLetter(LetterID);
}
/* 刪除字元對象後馬上再創建一個 */
CreateLetter();
}
void CreateLetter()
{
int i=0;
int x;
BYTE val;
if (LetterUsed==MAX_LETTER) return; /* 無字元對象可用則返回 */
while (Letter[++i].Used); /* 找到第一個空閑的字元對象,產生一個字元對象 */
x=i;
Letter[i].x=x*640/MAX_LETTER;
Letter[i].y=0;
Letter[i].val=random(26)+'A';
Letter[i].Used=TRUE;
LetterUsed++;
}
void HideLetter(int ID)
{
/* 用填充矩形來消隱字元 */
bar(Letter[ID].x,Letter[ID].y,Letter[ID].x+16,Letter[ID].y+20);
}
void ShowLetter(int ID)
{
char str[2]={0,0};
str[0]=Letter[ID].val;
outtextxy(Letter[ID].x,Letter[ID].y,str);
}
void Check(BYTE Key)
{
int i;
char str[6];
Hits++;
for (i=0;i<MAX_LETTER;i++)
/* 擊中 */
if (Letter[i].Used&&Letter[i].val==toupper(Key))
{
sound(1000);
delay(10);
KillLetter(i);
Right++;
nosound();
}
/* 顯示狀態 */
setfillstyle(SOLID_FILL,5);
bar(260,430,320,450);
bar(410,430,470,450);
setcolor(2);
sprintf(str," %4ld",Hits);
outtextxy(260,430,str);
sprintf(str," %4ld",Right);
outtextxy(410,430,str);
setcolor(7);
setfillstyle(SOLID_FILL,0);
}
void ShowBar()
{
FILE *bmp;
BYTE r,g,b,t;
int i,x,y;
bmp=fopen("bar.bmp","rb");
fseek(bmp,54,SEEK_SET);
for (i=0;i<16;i++)
{
setpalette(i,i);
b=fgetc(bmp)>>2;
g=fgetc(bmp)>>2;
r=fgetc(bmp)>>2;
t=fgetc(bmp)>>2;
setrgbpalette(i,r,g,b);
}
for (y=0;y<80;y++)
for (x=0;x<320;x++)
{
t=fgetc(bmp);
putpixel(x*2,479-y,t>>4);
putpixel(x*2+1,479-y,t&15);
}
fclose(bmp);
}
void SelectLevel()
{
int Steps[3]={1,2,4};
int Intervals[3]={18,9,5};
int Sel=0;
FILE *bmp;
BYTE r,g,b,t,Key;
int i,x,y;
bmp=fopen("sel.bmp","rb");
fseek(bmp,54,SEEK_SET);
for (i=0;i<16;i++)
{
setpalette(i,i);
b=fgetc(bmp)>>2;
g=fgetc(bmp)>>2;
r=fgetc(bmp)>>2;
t=fgetc(bmp)>>2;
setrgbpalette(i,r,g,b);
}
for (y=0;y<200;y++)
for (x=0;x<160;x++)
{
t=fgetc(bmp);
putpixel(x*2+160,339-y,t>>4);
putpixel(x*2+161,339-y,t&15);
}
fclose(bmp);
while (TRUE)
{
Key=toupper(AscKey());
if (Key=='A') Sel=1;
if (Key=='B') Sel=2;
if (Key=='C') Sel=3;
if (Sel) break;
}
Step=Steps[Sel-1];
Interval=Intervals[Sel-1];
cleardevice();
}
/*********************************************************/
/* 文件:TIMER.H */
/*********************************************************/
/*********************************************************/
/* 系統可用計時器的最大數目 */
# define MAXTIMER 10
# ifndef NULL
# define NULL 0
# endif
/* 計時器結構 */
struct TM
{
DWORD Interval; /* 間隔 */
DWORD LastTimer; /* 上次事件發生時間*/
BOOL Enable; /* 活動 */
BOOL Used; /* 可用 */
void (*Pointer)(); /* 事件遠指針 */
};
struct TM tmTM[MAXTIMER+1];
int TimerUsed=0;
/* 獲取BIOS計數器數值 */
DWORD BiosTimer(void)
{
DWORD BIOSTIMER=0;
BIOSTIMER=peek(0x0,0x46e);
BIOSTIMER<<=8;
BIOSTIMER+=peek(0x0,0x46c);
return (BIOSTIMER);
}
/* 時間事件(時鍾系統核心) */
void TimerEvent()
{
int i;
DWORD TimerDiff;
for (i=1;i<=MAXTIMER;i++)
{
if (tmTM[i].Used&&tmTM[i].Enable)
{
TimerDiff=BiosTimer()-tmTM[i].LastTimer;
if (tmTM[i].Interval<=TimerDiff)
{
tmTM[i].Pointer();
tmTM[i].LastTimer=BiosTimer();
}
}
}
}
/* 創建一個時鍾(成功返回時鍾的句柄,否則返回NULL) */
int CreateTimer(DWORD Interval,void (*Pointer)())
{
int i=0;
if (TimerUsed==MAXTIMER) return NULL;
while (tmTM[++i].Used);
tmTM[i].Pointer=Pointer;
tmTM[i].Interval=Interval;
tmTM[i].Enable=TRUE;
tmTM[i].Used=TRUE;
tmTM[i].LastTimer=BiosTimer();
TimerUsed++;
return i;
}
/* 刪除一個時鍾 */
void KillTimer(int *TimerID)
{
if (tmTM[*TimerID].Used)
{
TimerUsed--;
tmTM[*TimerID].Used=FALSE;
}
*TimerID=0;
}
/* 刪除所有時鍾 */
void KillAllTimer()
{
int i;
for (i=0;i<=MAXTIMER;i++) tmTM[i].Used=FALSE;
TimerUsed=0;
}
『叄』 C語言程序設計課程設計撲克牌游戲,怎麼做
#include<conio.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
int jisuan(int);
int comptotal;
char s1[]="A234567890JQK";
//char s2[4][5]={"紅桃","黑桃","草花","方塊"};
char s2[4]={3,4,5,6};
int poke[52];
int ch;
int win=0;
int computer[5],user[5];
int usertotal;
int users;
int k;
int main()
{ void xipai(int poke[]);
void ai();
int i,j;
////////////////////////////////////////////////////////上面是變數和聲明
printf("\n這是簡單的廿一點游戲:\n");
for(i=0;i<52;i++)
{
if(i%13==0)putchar('\n');
poke[i]=i;
printf("%c%c%c ",s2[i/13],s1[i%13]=='0'?'1':' ',s1[i%13]);
}
putchar('\n');
/////////////////////////////////////////////////////////主代碼
k=0;
xipai(poke);
while(ch!=27)
{ comptotal=0;
usertotal=0;
if(k>=42)
{
printf("\n剩餘牌數不足十張,重新洗牌");
xipai(poke);
k=0;
}
printf("\n\n\n\n\n\n\n\n新局開始:\n");
printf("現在共有牌%2d張\n",52-k);
if(win==0)
{
computer[0]=k++;
user[0]=k++;
printf("\n電腦做莊,要牌:");
ai();
}
else
{
printf("\n玩家做莊,要牌:\n\t回車要牌\n\t空格過牌");
user[0]=k++;
computer[0]=k++;
}
printf("\n玩家開始要牌:\n");
usertotal=jisuan(poke[user[0]]);
printf("%c%c%c 共%2d點\t",s2[poke[user[0]]/13],s1[poke[user[0]]%13]=='0'?'1':' ',s1[poke[user[0]]%13],usertotal);
users=0;
ch=1;
while(ch!=32&&users<4)
{
ch=getch();
switch(ch)
{
case 27:
goto end;
break;
case 32:
break;
case 13:
user[++users]=k;
usertotal+=jisuan(poke[user[users]]);
printf("\b\b\b\b\b\b\b\b\b%c%c%c 共%2d點\t",s2[poke[k]/13],s1[poke[k]%13]=='0'?'1':' ',s1[poke[k]%13],usertotal);
k++;
if(usertotal>=21)ch=32;
break;
default:
break;
}
}
if(win==1)
{
printf("\n電腦開始要牌:\n");
ai();
}
printf("\n\n\n玩家的點數是%2d",usertotal);
printf("\n電腦的點數是%2d",comptotal);
printf("\n\n本局結算:");
if(comptotal>21&&usertotal<=21)
{
printf("\n\n電腦爆牌了");
win=1;
printf("\n恭喜,你贏了");
}
if(usertotal>21&&comptotal<=21)
{
printf("\n\n你爆牌了");
printf("\n下次小心點");
win=0;
}
if(usertotal>21&&comptotal>21)
{
printf("\n\n你們兩個,怎麼都這么不小心啊,都撐死了還要嗎");
}
if(usertotal<=21&&comptotal<=21)
{
if(usertotal>comptotal)
{
win=1;
printf("\n\n不錯,你贏了");
}
else if(usertotal<comptotal)
{
win=0;
printf("\n\n撐死膽大的,餓死膽小的,沒膽子,輸了吧");
}
else
printf("\n\n平了,算你走運");
}
getch();
}
end:
return 0;
}
void xipai(int poke[])
{
int y,tmp,i,j;
for(j=0;j<7;j++)
for(i=0;i<52;i++)
{
srand(time(0));
y=rand()%10;
tmp=poke[i];
poke[i]=poke[(y*i*i)%52];
poke[(y*i*i)%52]=tmp;
}
}
///////////////////////////////////////////////子函數
void ai()
{
int i;
comptotal=jisuan(poke[computer[0]]);
printf("\n%c%c%c 共%2d點\t",s2[poke[computer[0]]/13],s1[poke[computer[0]]%13]=='0'?'1':' ',s1[poke[computer[0]]%13],comptotal);
for(i=0;i<4;i++)
{
if(comptotal<17)
{
computer[i+1]=k++;
comptotal+=jisuan(poke[computer[i+1]]);
printf("\b\b\b\b\b\b\b\b\b%c%c%c 共%2d點\t",s2[poke[computer[i+1]]/13],s1[poke[computer[i+1]]%13]=='0'?'1':' ',s1[poke[computer[i+1]]%13],comptotal);
}
}
}
int jisuan(int i)
{int dian;
switch(i%13)
{
case 0:
case 10:
case 11:
case 12:
dian=1;
break;
default:
dian=i%13+1;
}
return dian;
}
『肆』 怎麼用c語言實現數字回聲
回放,即延時輸出。
先將當前的數據讀取下來,保存,再加入上一次的數據,混合,再發聲。
F(n)=F(n)+F(n-1);
如果是多路回放,F(n)=F(n)+F(n-1)+F(n-2)........
『伍』 編寫C語言程序,模擬將一副撲克牌54張隨機分給4個人 (如何表達不同花色和大小,如何高效洗牌)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int poke[13][4],joker[2],last_four_card[4]; //定義四類十三張牌、雙王
int i,j,card,count,tank[54],player[20],computer[2][20];
bool flag;
srand(time(NULL)); //初始化隨機種子
for(i=0;i<54;i++)
tank[i]=-1; //初始化容器
for(i=0;i<54;i++)
{
flag=1;
while(flag)
{
flag=0;
card=rand()%54;
for(j=0;j<=i;j++)
if(card==tank[j]) flag=1;
}
tank[i]=card;
}
count=0;
for(i=0;i<54;i++)
{
if(tank[i]==52) printf("jok ");
else if(tank[i]==53) printf("JOK ");
else if(tank[i]%13==0) printf("%c%c ",tank[i]/13+3,'A');
else if(tank[i]%13==10) printf("%c%c ",tank[i]/13+3,'J');
else if(tank[i]%13==11) printf("%c%c ",tank[i]/13+3,'Q');
else if(tank[i]%13==12) printf("%c%c ",tank[i]/13+3,'K');
else if(tank[i]%13<10) printf("%c%-2d ",tank[i]/13+3,tank[i]%13+1);
count++;
if(count%20==0) printf("\n");
}
count=0;
for(i=0;i<16;i++)
{
player[i]=tank[i];
computer[0][i]=tank[i+16];
computer[1][i]=tank[i+32];
}
for(i=0;i<4;i++)
last_four_card[i]=tank[53-i];
printf("\n\n你的牌是:\n\n");
for(i=0;i<16;i++)
{
if(player[i]==52) printf("jok ");
else if(player[i]==53) printf("JOK ");
else if(player[i]%13==0) printf("%c%c ",player[i]/13+3,'A');
else if(player[i]%13==10) printf("%c%c ",player[i]/13+3,'J');
else if(player[i]%13==11) printf("%c%c ",player[i]/13+3,'Q');
else if(player[i]%13==12) printf("%c%c ",player[i]/13+3,'K');
else if(player[i]%13<10) printf("%c%-2d ",player[i]/13+3,player[i]%13+1);
count++;
if(count%20==0) printf("\n");
}
getchar();
getchar();
return 0;
}
以前無聊寫的 給你作參考吧