


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、學(xué)生成績管理系統(tǒng)(c語言)課程設(shè)計報告學(xué)生成績管理系統(tǒng) 要求是這樣的1、 用c語言編寫一個簡單的學(xué)生信息管理程序,能實現(xiàn)對學(xué)生信息的簡單管理 。2、具體要求:建立一個4個學(xué)生的信息登記表,每個學(xué)生的信息包括:學(xué)號,姓名,和3門課程的成績(FOX,C,ENGLISH)。程序運行時顯示一個簡單的菜單,例如:(1):信息輸入(INPUT)(2):總分統(tǒng)計(COUNT)(3):總分排序(SORT)(4):查詢(QUERY)其中:(1):對4個學(xué)生的信息進行輸入;(2):對每個學(xué)生的3門課程統(tǒng)計總分;(3):對4個學(xué)生的總分按降序排序并顯示岀來;(4):查詢輸入一個學(xué)號后,顯示出該學(xué)生的有關(guān)信息; 偶先
2、寫了個# i nclude<iostream.h># i nclude<stdlib.h> struct studentint num;char name20;int foxscore;int cscore;int englishscore;struct student *next;void menu()coutvv"welecome to my student grade management system"vvendl;coutvv"please follow everyone step in the menu"vvendl;
3、coutvv"1.input information"vvendl;coutvv"2.total scores"vvendl;coutvv"3.sort"vvendl;coutvv"4.query"vvendl;coutvv"*"vve ndl*struct student *creat(struct student *head) /函數(shù)返回的是與節(jié)點相同類型的指針struct student *p1,*p2;輸入節(jié)點的值p1=p2=(struct student*) malloc(sizeof
4、(struct student); /申請新節(jié)點cin»p1->num>>p1->name>>p1->foxscore>>p1->cscore»p1->englishscore; / p1-> next = NULL; /將新節(jié)點的指針置為空while(p1->num>0)if (head=NULL) head=p1; / 空表,接入表頭else p2->next=p1; / 非空表,接到表尾p2 = p1;p1=(struct student *)malloc(sizeof(stru
5、ct student); /申請下一個新節(jié)點cin>>p1->num>>p1->name>>p1->foxscore>>p1->cscore>>p1->englishscore;/輸入節(jié)點的值return head; / 返回鏈表的頭指針 void count(struct student *head)struct student *temp;temp=head; / 取得鏈表的頭指針while(temp!=NULL)int m; m=temp->foxscore+temp->cscore+t
6、emp->englishscore;coutvvmvvendl;/輸出鏈表節(jié)點的值temp=temp->next; /跟蹤鏈表增長void sort(struct student *head)struct student *tp;tp=head;int a4;定義總分?jǐn)?shù)組int i,j,k;while(temp!=NULL)ai=tp->foxscore+tp->cscore+tp->englishscore;tp=tp->next;i=i+1;for(j=i;jv=3;j+)冒泡法排序for(k=1;k<=4-j;k+)if(ak<ak+1)i
7、nt t=ak;ak=ak+1;ak+1=t;for(i=1;i<5;i+)cout<vaivvendl;void query(struct student *head)struct student *temper;temper=head;int number;cin»number;for(int i=1;i<=4;i+)if(number=temper->num)coutvv"name isEwtemper-Anamevvendl;coutvv"fox score is:"vvtemper->foxscorevvendl;
8、coutvv"c score is:"vvtemper->cscorevvendl;coutvv" English score is:"vvtemper->englishscorevvendl;coutvv"congratulation,syetem have found what you want to search"vvendl;temper=temper->next;void main()menu();coutvv" firstly,please input information:"vve
9、ndl;struct student *head;head=NULL;/* 建一個空表 */head=creat(head); /* 創(chuàng)建單鏈表 */coutvv" secondly,count the total score each student:"vvendl;count(head);coutvv" thirdly,sorting the total score:"vvendl;sort(head);coutvv" enter num that you can search each shtudent's information
10、"vvendl; query(head);coutvv"thanks you for use my student grade management system"vvendl;編譯時候都沒有錯.debug輸入時候出現(xiàn)了錯誤.調(diào)試運行后發(fā)現(xiàn)原來是while循環(huán)出了問題啊修改后# i nclude<iostream.h># i nclude<stdlib.h>struct studentint num;char name20;int foxscore;int cscore;int englishscore;struct student *ne
11、xt;void menu() coutvv"welecome to my student grade management system"<<endl;coutvv" please follow everyone step in the menu"<<endl;coutvv"l.input information"<<endl;coutvv"2.total scores"vvendl;coutvv"3.sort"vvendl;coutvv"4.que
12、ry"vvendl;coutvv"*vvendl;struct student *creat(struct student *head) /函數(shù)返回的是與節(jié)點相同類型的指針struct student *p1,*p2;輸入節(jié)點的值p1=p2=(struct student*) malloc(sizeof(struct student); /申請新節(jié)點cin>>p1->num»p1->name>>p1->foxscore>>p1->cscore»p1->englishscore; / p1-
13、> next = NULL; / 將新節(jié)點的指針置為空for(int i=1;iv=4;i+)if (head=NULL) head=p1; / 空表,接入表頭else p2->next=p1; / 非空表,接到表尾p2 = p1;p1=(struct student *)malloc(sizeof(struct student); /申請下一個新節(jié)點if(iv=3) cin>>p1->num>>p1->name>>p1->foxscore>>p1->cscore>>p1->englishsc
14、ore;/輸入節(jié)點的值return head; / 返回鏈表的頭指針 void count(struct student *head)struct student *temp;temp=head; / 取得鏈表的頭指針for(int i=1;i<=4;i+)int m; m=temp->foxscore+temp->cscore+temp->englishscore;coutvvmvvendl;/ 輸出鏈表節(jié)點的值temp=temp->next; / 跟蹤鏈表增長void sort(struct student *head)struct student *tp;t
15、p=head;int a4;定義總分?jǐn)?shù)組int i,j,k;a1=tp->foxscore+tp->cscore+tp->englishscore; tp=tp->next;a2=tp->foxscore+tp->cscore+tp->englishscore; tp=tp->next;a3=tp->foxscore+tp->cscore+tp->englishscore; tp=tp->next;a4=tp->foxscore+tp->cscore+tp->englishscore;for(j=1;j&
16、lt;=3;j+)/ 冒泡法排序 for(k=1;k<=4-j;k+)if(ak<ak+1)int t=ak;ak=ak+1;ak+1=t;for(i=1;i<5;i+)cout<<aivvendl;void query(struct student *head)struct student *temper;temper=head;int number;cin»number;for(int i=1;i<=4;i+)if(number=temper->num)coutvv"name is:"<<temper-&g
17、t;name<<endl;coutvv"fox score is:"vvtemper->foxscorevvendl;coutvv"c score is:"vvtemper->cscorevvendl;coutvv" English score is:"vvtemper->englishscorevvendl;coutvv"congratulation,syetem have found what you want to search"vvendl;temper=temper->
18、next;void main()menu();coutvv" firstly,please input information:"vvendl;struct student *head;head=NULL;/* 建一個空表 */head=creat(head); /* 創(chuàng)建單鏈表 */coutvv" secondly,count the total score each student:"vvendl;count(head);coutvv" thirdly,sorting the total score:"vvendl;sort(he
19、ad);coutvv" enter num that you can search each shtudent's information"vvendl; query(head);coutvv"thanks you for use my student grade management system"vvendl;C語言課程設(shè)計一貪吃蛇代碼#define N 200#include vgraphics.h>#include vstdlib.h>#include vdos.h>#define LEFT 0x4b00#define
20、RIGHT 0x4d00#define DOWN 0x5000#define UP 0x4800#define ESC 0x011bint i,key;int score=0;/* 得分 */int gamespeed=50000;/* 游戲速度自己調(diào)整*/struct Foodint x;/*食物的橫坐標(biāo)*/int y;/*食物的縱坐標(biāo)*/int yes;/*判斷是否要出現(xiàn)食物的變量*/food;/*食物的結(jié)構(gòu)體*/struct Snakeint xN;int yN;int node;/*蛇的節(jié)數(shù)*/int direction;/* 蛇移動方向 */int life;/* 蛇的生命,0活著,
21、1死亡*/snake;void Init(void);/* 圖形驅(qū)動 */void Close(void);/* 圖形結(jié)束 */void DrawK(void);/* 開始畫面 */void GameOver(void);/*結(jié)束游戲 */void GamePlay(void);/*玩游戲具體過程 */void PrScore(void);/* 輸出成績 */*主函數(shù)*/void main(void)Init();/*圖形驅(qū)動*/DrawK();/*開始畫面*/GamePlay();/*玩游戲具體過程*/Close();/*圖形結(jié)束*/*圖形驅(qū)動*/void Init(void)int gd=
22、DETECT,gm;initgraph(&gd, &gm,"c:tc");cleardevice();/*開始畫面,左上角坐標(biāo)為(50,40),右下角坐標(biāo)為(610, 460)的圍墻*/void DrawK(void)/*setbkcolor(LIGHTGREEN);*/setcolor(11);setlinestyle(SOLID_LINE,0,THICK_WIDTH);/* 設(shè)置線型 */for(i=50;i<=600;i+=10)/* 畫圍墻 */rectangle(i,40,i+10,49); /* 上邊 */rectangle(i,451,i
23、+10,460);/* 下邊 */for(i=40;i<=450;i+=10)rectangle(50,i,59,i+10); /* 左邊 */rectangle(601,i,610,i+10);/* 右邊 */*玩游戲具體過程*/void GamePlay(void)randomize。;/*隨機數(shù)發(fā)生器*/food.yes=1;/*1表示需要出現(xiàn)新食物,0表示已經(jīng)存在食物*/snake.life=O;/* 活著 */snake.direction=1;/* 方向往右 */snake.x0=100;snake.y0=100;/* 蛇頭 */snake.x1=110;snake.y1=1
24、00;snake.node=2;/* 節(jié)數(shù) */PrScore();/* 輸出得分 */while(1)/*可以重復(fù)玩游戲,壓ESC鍵結(jié)束*/while(!kbhit()/*在沒有按鍵的情況下,蛇自己移動身體*/if(food.yes=1)/*需要出現(xiàn)新食物*/food.x=rand()%400+60;,這樣才可以讓蛇吃到*/food.y=rand()%350+60;while(food.x%10!=0)/*食物隨機出現(xiàn)后必須讓食物能夠在整格內(nèi)food.x+;while(food.y%10!=0)food.y+;food.yes=0;/* 畫面上有食物了 */if(food.yes=0)/*畫
25、面上有食物了就要顯示 */setcolor(GREEN);rectangle(food.x,food.y,food.x+10,food.y-10);for(i=snake.node-1;i>0;i-)/*蛇的每個環(huán)節(jié)往前移動,也就是貪吃蛇的關(guān)鍵算法*/snake.xi=snake.xi-1;snake.yi=snake.yi-1;/*1,2,3,4表示右,左,上,下四個方向,通過這個判斷來移動蛇頭*/switch(snake.direction)case 1:snake.x0+=10;break;case 2: snake.x0-=10;break;case 3: snake.y0-=1
26、0;break;case 4: snake.y0+=10;break;,第三節(jié)不可能for(i=3;i<snake.node;i+)/*從蛇的第四節(jié)開始判斷是否撞到自己了 ,因為蛇頭為兩節(jié)拐過來*/if(snake.xi=snake.x0&&snake.yi=snake.y0)GameOver();/* 顯示失敗 */snake .li fe=1;break;if(snake.x0<55|snake.x0>595|snake.y0<55|snake.y0>455)/*蛇是否撞到墻壁*/GameOver();/*本次游戲結(jié)束*/snake.1 ife
27、=1; /* 蛇死 */if(snake.life=1)/*以上兩種判斷以后,如果蛇死就跳出內(nèi)循環(huán),重新開始*/break;if(snake.x0=food.x&&snake.y0=food.y)/*吃到食物以后 */setcolor(0);/*把畫面上的食物東西去掉*/rectangle(food.x,food.y,food.x+10,food.y-10); snake.xsnake.node=-20;snake.ysnake.node=-20;/*新的一節(jié)先放在看不見的位置,下次循環(huán)就取前一節(jié)的位置*/snake.node+;/* 蛇的身體長一節(jié)*/food.yes=1;/
28、*畫面上需要出現(xiàn)新的食物*/score+=10;PrScore();/*輸出新得分*/setcolor(4);/* 畫出蛇 */for(i=0;i<snake.node;i+)rectangle(snake.xi,snake.yi,snake.xi+10,snake.yi-10);delay(gamespeed);setcolor(0);/*用黑色去除蛇的的最后一節(jié)*/rectangle(snake.xsnake.node-1,snake.ysnake.node-1,snake.xsnake.node-1+10,snake.ysnake.node-1-10); /*endwhile (!
29、 kbhit) */if(snake.life=1)/* 如果蛇死就跳出循環(huán)*/break;key=bioskey(0);/* 接收按鍵 */if(key=ESC)/* 按 ESC鍵退出 */break;elseif(key=UP&&snake.direction!=4)/*判斷是否往相反的方向移動*/snake.direction=3;elseif(key=RIGHT&&snake.direction!=2) snake.direction=1;elseif(key=LEFT&&snake.direction!=1)snake.directio
30、n=2;elseif(key=DOWN&&snake.direction!=3)snake.direction=4;/*endwhile(1)*/*游戲結(jié)束*/void GameOver(void)cleardevice();PrScore();setcolor(RED);settextstyle(0,0,4);outtextxy(200,200,"GAME OVER"); getch();/*輸岀成績*/void PrScore(void)char str10;setfillstyle(SOLID_FILL,YELLOW);bar(50,15,220,35
31、);setcolor(6);settextstyle(0,0,2);sprintf(str,"score:%d",score);outtextxy(55,20,str);/*圖形結(jié)束*/void Close(void)getch();closegraph();C語言課程設(shè)計_貪吃蛇代碼,不錯啊c語言課程設(shè)計#include <dos.h>#include <math.h>#include <conio.h>#include <stdio.h>#include <stdlib.h>#include <stdar
32、g.h> #include <graphics.h>計算器設(shè)計/*DOS接口函數(shù)*/*數(shù)學(xué)函數(shù)的定義*/*屏幕操作函數(shù)*/*1/0 函數(shù) */*庫函數(shù)*/*變量長度參數(shù)表*/*圖形函數(shù)*/*字符串函數(shù)*/*字符操作函數(shù)*/*光標(biāo)上移鍵*/*光標(biāo)下移鍵*/*光標(biāo)左移鍵*/*光標(biāo)右移鍵*/*回車鍵*/#include <string.h> #include <ctype.h> #define UP 0x48#define DOWN 0x50#define LEFT 0x4b#define RIGHT 0x4d#define ENTER 0x0dvoid *
33、rar;/*全局變量,保存光標(biāo)圖象*/struct palettetype palette; /*使用調(diào)色板信息 */intGraphDriver; /*圖形設(shè)備驅(qū)動*/intGraphMode; /*圖形模式值*/intErrorCode; /*錯誤代碼*/intMaxColors; /*可用顏色的最大數(shù)值*/intMaxX, MaxY; /*屏幕的最大分辨率*/double AspectRatio; /* 屏幕的像素比 */void drawboder(void); /*畫邊框函數(shù) */void initialize(void); /* 初始化函數(shù) */*改變文本樣式函數(shù)*/void co
34、mputer(void);/* 計算器計算函數(shù) */void changetextstyle(int font, int direction, int charsize);void mwindow(char *header); /* 窗口函數(shù) */int specialkey(void) ;/* 獲取特殊鍵函數(shù) */int arrow();/*設(shè)置箭頭光標(biāo)函數(shù)*/*主函數(shù)*/int main()initialize。;/* 設(shè)置系統(tǒng)進入圖形模式*/computer。; /*運行計算器*/ closegraph();/*系統(tǒng)關(guān)閉圖形模式返回文本模式*/return(O); /* 結(jié)束程序 */*
35、設(shè)置系統(tǒng)進入圖形模式 */void initialize(void)int xasp, yasp; /* 用于讀x和y方向縱橫比*/GraphDriver = DETECT;/*自動檢測顯示器 */initgraph( & GraphDriver, & GraphMode,"");/*初始化圖形系統(tǒng)*/ErrorCode = graphresult(); /*讀初始化結(jié)果 */if( ErrorCode != grOk )/*如果初始化時出現(xiàn)錯誤 */printf("Graphics System Error: %sn",grapherr
36、ormsg( ErrorCode ) ); /*顯示錯誤代碼 */exit( 1 );/* 退出 */getpalette( &palette ); /* 讀面板信息 */MaxColors = getmaxcolor() + 1; /*讀取顏色的最大值 */MaxX = getmaxx(); /* 讀屏幕尺寸 */MaxY = getmaxy(); /* 讀屏幕尺寸 */getaspectratio( &xasp, &yasp ); /*拷貝縱橫比到變量中 */AspectRatio = (double)xasp/(double)yasp;/*計算縱橫比值 */*計算
37、器函數(shù)*/ void computer(void)struct viewporttype vp;/* 定義視口類型變量 */int color, height, width;int x, y,x0,y0, i, j,v,m,n,act,flag=1;float num仁0,num2=0,result;/*操作數(shù)和計算結(jié)果變量 */char cnum5,str220="",c,temp20=""char str1="1230.456+-789*/Qc=A%"/*定義字符串在按鈕圖形上顯示的符號*/mwindow( "Calcu
38、lator" );/* 顯示主窗口*/color = 7;/*設(shè)置灰顏色值*/getviewsettings( &vp );/* 讀取當(dāng)前窗口的大小 */width=(vp.right+1)/10;/* 設(shè)置按鈕寬度*/height=(vp.bottom-10)/10 ;/* 設(shè)置按鈕高度*/x = width /2;/*設(shè)置x的坐標(biāo)值*/y = height/2; /* 設(shè)置y的坐標(biāo)值*/setfillstyle(SOLID_FILL, color+3);bar( x+width*2, y, x+7*width, y+height );/*畫一個二維矩形條顯示運算數(shù)和結(jié)果
39、*/setcolor( colo葉3 );/*設(shè)置淡綠顏色邊框線 */rectangle( x+width*2, y, x+7*width, y+height );/*畫一個矩形邊框線*/setcolor(RED); /*設(shè)置顏色為紅色*/outtextxy(x+3*width,y+height/2,"0."); /* 輸出字符串"0."*/x =2*width-width/2; /* 設(shè)置 x 的坐標(biāo)值 */y =2*height+height/2; /*設(shè)置 y 的坐標(biāo)值 */for( j=0 ; j<4 ; +j ) /* 畫按鈕 */for
40、( i=0 ; i<5 ; +i )setfillstyle(SOLID_FILL, color);setcolor(RED);bar( x, y, x+width, y+height ); /*畫一個矩形條 */rectangle( x, y, x+width, y+height );sprintf(str2,"%c",str1j*5+i);/*將字符保存到str2中*/outtextxy( x+(width/2), y+height/2, str2);x =x+width+ (width / 2) ; /*移動列坐標(biāo) */y +=(height/2)*3; /*移
41、動行坐標(biāo) */x =2*width-width/2; /* 復(fù)位列坐標(biāo) */x0=2*width;y0=3*height;x=x0;y=yO;gotoxy(x,y);/*移動光標(biāo)到x,y位置*/arrow(); /*顯示光標(biāo)*/putimage(x,y,rar,XOR_PUT);m=0;n=0;strcpy(str2,""); /* 設(shè)置 str2 為空串 */否則執(zhí)行下面的循環(huán)*/*/*/while(v=specialkey()!=45) /* 當(dāng)壓下 Alt+x 鍵結(jié)束程序, while(v=specialkey()!=ENTER) /* 當(dāng)壓下鍵不是回車時 putim
42、age(x,y,rar,XOR_PUT); /* 顯示光標(biāo)圖象 */ if(v=RIGHT)/*右移箭頭時新位置計算*/if(x>=x0+6*width)/*如果右移,移到尾,則移動到最左邊字符位置x=x0;m=0;elsex=x+width+width/2;m+; /*否則,右移到下一個字符位置*/if(v=LEFT) /*左移箭頭時新位置計算*/if(x<=x0)x=x0+6*width;m=4; /*如果移到頭,再左移,則移動到最右邊字符位置*/elsex=x-width-width/2;m-; /*否則,左移到前一個字符位置*/if(v=UP)/*上移箭頭時新位置計算*/i
43、f(yv=yO)y=y0+4*height+height/2;n=3; /*如果移到頭,再上移,則移動到最下邊字符位置*/elsey=y-height-height/2;n-; /*否則,移到上邊一個字符位置*/if(v=DOWN) /*下移箭頭時新位置計算*/if(y>=7*height)y=yO;n=0; /*如果移到尾,再下移,則移動到最上邊字符位置*/elsey=y+height+height/2;n+; /*否則,移到下邊一個字符位置*/putimage(x,y,rar,XOR_PUT); /*在新的位置顯示光標(biāo)箭頭 */c=str1n*5+m;/*將字符保存到變量c中*/if
44、(isdigit(c)|c='.') /*判斷是否是數(shù)字或小數(shù)點*/if(flag=-1)/*如果標(biāo)志為-1,表明為負(fù)數(shù)*/strcpy(str2,"-"); /*將負(fù)號連接到字符串中*/flag=1; /*將標(biāo)志值恢復(fù)為1*/sprintf(temp,"%c",c); /*將字符保存到字符串變量temp中*/strcat(str2,temp); /* 將temp中的字符串連接到str2中*/setfillstyle(SOLID_FILL,colo r+3);bar(2*width+width/2,height/2,15*width/2,
45、3*height/2);outtextxy(5*width,height,str2);/*顯示字符串 */if(c='+')num仁atof(str2);/*將第一個操作數(shù)轉(zhuǎn)換為浮點數(shù)*/strcpy(str2,""); /* 將 str2 清空 */act=1;/*做計算加法標(biāo)志值*/setfillstyle(SOLID_FILL,colo r+3);bar(2*width+width/2,height/2,15*width/2,3*height/2);outtextxy(5*width,height,"0."); /* 顯示字符串 *
46、/if(c='-')if(strcmp(str2,"")=0) /* 如果str2為空,說明是負(fù)號,而不是減號*/ flag=-1;/*設(shè)置負(fù)數(shù)標(biāo)志*/elsenum仁atof(str2);/*將第二個操作數(shù)轉(zhuǎn)換為浮點數(shù)*/strcpy(str2,""); /* 將 str2 清空 */act=2; /*做計算減法標(biāo)志值*/setfillstyle(SOLID_FILL,colo r+3);bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形 */outtextxy(5*wi
47、dth,height,"0.");/*顯示字符串 */if(c='*')num仁atof(str2); /*將第二個操作數(shù)轉(zhuǎn)換為浮點數(shù)*/strcpy(str2,""); /* 將 str2 清空 */act=3; /*做計算乘法標(biāo)志值*/setfillstyle(SOLID_FILL,colo r+3);bar(2*width+width/2,height/2,15*width/2,3*height/2);outtextxy(5*width,height,"0."); /* 顯示字符串 */if(c='/
48、39;)num仁atof(str2); /*將第二個操作數(shù)轉(zhuǎn)換為浮點數(shù)*/strcpy(str2,""); /* 將 str2 清空 */act=4; /*做計算除法標(biāo)志值*/setfillstyle(SOLID_FILL,colo r+3);bar(2*width+width/2,height/2,15*width/2,3*height/2);outtextxy(5*width,height,"0."); /* 顯示字符串 */if(c='A')num仁atof(str2); /*將第二個操作數(shù)轉(zhuǎn)換為浮點數(shù)*/strcpy(str2,&
49、quot;"); /* 將 str2 清空 */act=5;/*做計算乘方標(biāo)志值*/setfillstyle(SOLID_FILL,colo葉3); /*設(shè)置用淡綠色實體填充bar(2*width+width/2,height/2,15*width/2,3*height/2); /* outtextxy(5*width,height,"0."); /* 顯示字符串 */if(c=%)num仁atof(str2); /*將第二個操作數(shù)轉(zhuǎn)換為浮點數(shù)*/strcpy(str2,""); /* 將 str2 清空 */act=6; /*做計算模運算乘方
50、標(biāo)志值*/setfillstyle(SOLID_FILL,colo葉3); /*設(shè)置用淡綠色實體填充bar(2*width+width/2,height/2,15*width/2,3*height/2); /* outtextxy(5*width,height,"0."); /* 顯示字符串 */if(c='=')num2=atof(str2); /*將第二個操作數(shù)轉(zhuǎn)換為浮點數(shù)*/switch(act) /*根據(jù)運算符號計算*/case 1:result=num1+num2;break; /* 做加法 */case 2:result=num1-num2;br
51、eak; /*做減法*/case 3:result=num1*num2;break; /*做乘法*/case 4:result=num1/num2;break; /*做除法*/case 5:result=pow(num1,num2);break; /* 做 x 的 y 次方 */case 6:result=fmod(num1,num2);break; /* 做模運算 */setfillstyle(SOLID_FILL,colo葉3); /*設(shè)置用淡綠色實體填充*/畫矩形*/*/畫矩形*/*/覆蓋結(jié)果區(qū)*/bar(2*width+width/2,height/2,15*width/2,3*hei
52、ght/2); /*sprintf(temp,"%f",result);/*將結(jié)果保存到 temp 中*/outtextxy(5*width,height,temp); /* 顯示結(jié)果 */if(c='c')num仁0;/*將兩個操作數(shù)復(fù)位 0,符號標(biāo)志為1*/num2=0;flag=1;strcpy(str2,""); /* 將 str2 清空 */setfillstyle(SOLID_FILL,colo 葉3);/* 設(shè)置用淡綠色實體填充 */bar(2*width+width/2,height/2,15*width/2,3*heig
53、ht/2); /*覆蓋結(jié)果區(qū) */outtextxy(5*width,height,"0."); /* 顯示字符串 */if(c=Q)exit(0);/*如果選擇了 q回車,結(jié)束計算程序*/putimage(x,y,rar,XOR_PUT); /*在退出之前消去光標(biāo)箭頭 */return; /* 返回 */*窗口函數(shù)*/void mwindow( char *header )int height;cleardevice(); /* 清除圖形屏幕*/setcolor( MaxColors - 1 ); /*設(shè)置當(dāng)前顏色為白色 */setviewport( 20, 20, Ma
54、xX/2, MaxY/2, 1 ); /* 設(shè)置視口大小 */height = textheight( "H" );/* 讀取基本文本大小*/settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );/* 設(shè)置文本樣式 */ settextjustify( CENTER_TEXT, TOP_TEXT );/* 設(shè)置字符排列方式 */ outtextxy( MaxX/4, 2, header );/* 輸出標(biāo)題 */setviewport( 20,20+height+4, MaxX/2+4, MaxY/2+20, 1 );/* 設(shè)置視口大小 */d
55、rawboder(); /* 畫邊框 */void drawboder(void) /* 畫邊框 */struct viewporttype vp;/* 定義視口類型變量 */setcolor( MaxColors - 1 ); /*設(shè)置當(dāng)前顏色為白色*/setlinestyle( SOLID_LINE, 0, NORM_WIDTH );/*設(shè)置畫線方式 */getviewsettings( &vp );/*將當(dāng)前視口信息裝入vp所指的結(jié)構(gòu)中*/rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top ); /*畫矩形邊框 */*設(shè)計鼠標(biāo)圖
56、形函數(shù)*/int arrow()int size;int raw=4,4,4,8,6,8,14,16,16,16,8,6,8,4,4,4; /*定義多邊形坐標(biāo) */setfillstyle(SOLID_FILL,2); /* 設(shè)置填充模式 */fillpoly(8,raw);/* 畫出一光標(biāo)箭頭 */size=imagesize(4,4,16,16); /* 測試圖象大小 */rar=malloc(size); /*分配內(nèi)存區(qū)域 */getimage(4,4,16,16,rar); /* 存放光標(biāo)箭頭圖象 */putimage(4,4,rar,XOR_PUT); /* 消去光標(biāo)箭頭圖象 */r
57、eturn 0;/*按鍵函數(shù)*/int specialkey(void)int key;while(bioskey(1)=0); /* 等待鍵盤輸入 */key=bioskey(0);/*鍵盤輸入 */key=key&0xff? key&0xff:key>>8;/*只取特殊鍵的掃描值,其余為0*/return(key); /* 返回鍵值 */c語言課程設(shè)計計算器設(shè)計C語言課程設(shè)計_進程調(diào)度文章發(fā)布:課程設(shè)計網(wǎng) 發(fā)布時間:2006-10-18進程調(diào)度代碼#include "stdio.h"#include "stdlib.h"#include "string.h"typedef struct nodechar na
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 片上系統(tǒng)功耗管理-深度研究
- 光伏陣列陰影效應(yīng)分析-深度研究
- 舞蹈藝術(shù)與科技-深度研究
- 肥胖干預(yù)營養(yǎng)干預(yù)方案對比-深度研究
- 身體運動與社會網(wǎng)絡(luò)結(jié)構(gòu)的關(guān)系-深度研究
- 跨界融合-電視內(nèi)容多元化-深度研究
- 智能制造與智能工廠-深度研究
- 云服務(wù)自動化運維的挑戰(zhàn)與對策-深度研究
- 跨語言醫(yī)學(xué)信息檢索-深度研究
- 貫黃感冒顆粒國際市場前景-深度研究
- 婦產(chǎn)科醫(yī)療質(zhì)控月匯報
- 《石油化工企業(yè)場地地下水污染防治技術(shù)指南》(T-CAEPI 39-2021)
- 人大代表身份證明
- 部編版語文四年級下冊第二單元大單元教學(xué)設(shè)計核心素養(yǎng)目標(biāo)
- 城區(qū)排水管網(wǎng)雨污分流改造項目可行性報告
- 公務(wù)員因私出國規(guī)定
- 《幼兒教育評價》課程標(biāo)準(zhǔn)
- 《現(xiàn)代教育技術(shù)》課程標(biāo)準(zhǔn)
- 教職工安全教育培訓(xùn)課件
- 2024年山東省春季高考技能考試-汽車專業(yè)備考試題庫(濃縮500題)
- 2024年湖南生物機電職業(yè)技術(shù)學(xué)院高職單招(英語/數(shù)學(xué)/語文)筆試歷年參考題庫含答案解析
評論
0/150
提交評論