亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

程序中的顏色和邊框的函數怎么來運用?求大佬指點

程序中的顏色和邊框的函數怎么來運用?求大佬指點

C
ibeautiful 2023-04-23 18:14:08
是編寫一個計算器不過是要復雜一點比如1.加法 2.減法 3.乘法 4.除法 5.退出輸入:-----如果輸入1.進行加法2.進行減法·····5.退出我是用中文說的當然用那個C語言是用英文的還有就是把背景弄一下謝謝了
查看完整描述

2 回答

?
慕村9548890

TA貢獻1884條經驗 獲得超4個贊

f(c=='-') 

if(strcmp(str2,"")==0) /*如果str2為空,說明是負號,而不是減號*/ 
flag=-1; /*設置負數標志*/ 
else 

num1=atof(str2); /*將第二個操作數轉換為浮點數*/ 
strcpy(str2,""); /*將str2清空*/ 
act=2; /*做計算減法標志值*/ 
setfillstyle(SOLID_FILL,color+3); 
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/ 
outtextxy(5*width,height,"0."); /*顯示字符串*/ 


if(c=='*') 

num1=atof(str2); /*將第二個操作數轉換為浮點數*/ 
strcpy(str2,""); /*將str2清空*/ 
act=3; /*做計算乘法標志值*/ 
setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2); 
outtextxy(5*width,height,"0."); /*顯示字符串*/ 

if(c=='/') 

num1=atof(str2); /*將第二個操作數轉換為浮點數*/ 
strcpy(str2,""); /*將str2清空*/ 
act=4; /*做計算除法標志值*/ 
setfillstyle(SOLID_FILL,color+3); 
bar(2*width+width/2,height/2,15*width/2,3*height/2); 
outtextxy(5*width,height,"0."); /*顯示字符串*/ 

if(c=='^') 

num1=atof(str2); /*將第二個操作數轉換為浮點數*/ 
strcpy(str2,""); /*將str2清空*/ 
act=5; /*做計算乘方標志值*/ 
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/ 
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/ 
outtextxy(5*width,height,"0."); /*顯示字符串*/ 

if(c=='%') 

num1=atof(str2); /*將第二個操作數轉換為浮點數*/ 
strcpy(str2,""); /*將str2清空*/ 
act=6; /*做計算模運算乘方標志值*/ 
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/ 
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/ 
outtextxy(5*width,height,"0."); /*顯示字符串*/ 

if(c=='=') 

num2=atof(str2); /*將第二個操作數轉換為浮點數*/ 
switch(act) /*根據運算符號計算*/ 

case 1:result=num1+num2;break; /*做加法*/ 
case 2:result=num1-num2;break; /*做減法*/ 
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,color+3); /*設置用淡綠色實體填充*/ 
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆蓋結果區*/ 
sprintf(temp,"%f",result); /*將結果保存到temp中*/ 
outtextxy(5*width,height,temp); /*顯示結果*/ 

if(c=='c') 

num1=0; /*將兩個操作數復位0,符號標志為1*/ 
num2=0; 
flag=1; 
strcpy(str2,""); /*將str2清空*/ 
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/ 
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆蓋結果區*/ 
outtextxy(5*width,height,"0."); /*顯示字符串*/ 

if(c=='Q')exit(0); /*如果選擇了q回車,結束計算程序*/ 

putimage(x,y,rar,XOR_PUT); /*在退出之前消去光標箭頭*/ 
return; /*返回*/ 

/*窗口函數*/ 
void mwindow( char *header ) 

int height; 
cleardevice(); /* 清除圖形屏幕 */ 
setcolor( MaxColors - 1 ); /* 設置當前顏色為白色*/ 
setviewport( 20, 20, MaxX/2, MaxY/2, 1 ); /* 設置視口大小 */ 
height = textheight( "H" ); /* 讀取基本文本大小 */ 
settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );/*設置文本樣式*/ 
settextjustify( CENTER_TEXT, TOP_TEXT );/*設置字符排列方式*/ 
outtextxy( MaxX/4, 2, header ); /*輸出標題*/ 
setviewport( 20,20+height+4, MaxX/2+4, MaxY/2+20, 1 ); /*設置視口大小*/ 
drawboder(); /*畫邊框*/ 

void drawboder(void) /*畫邊框*/ 

struct viewporttype vp; /*定義視口類型變量*/ 
setcolor( MaxColors - 1 ); /*設置當前顏色為白色 */ 
setlinestyle( SOLID_LINE, 0, NORM_WIDTH );/*設置畫線方式*/ 
getviewsettings( &vp );/*將當前視口信息裝入vp所指的結構中*/ 
rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top ); /*畫矩形邊框*/ 

/*設計鼠標圖形函數*/ 
int arrow() 

int size; 
int raw[]={4,4,4,8,6,8,14,16,16,16,8,6,8,4,4,4}; /*定義多邊形坐標*/ 
setfillstyle(SOLID_FILL,2); /*設置填充模式*/ 
fillpoly(8,raw); /*畫出一光標箭頭*/ 
size=imagesize(4,4,16,16); /*測試圖象大小*/ 
rar=malloc(size); /*分配內存區域*/ 
getimage(4,4,16,16,rar); /*存放光標箭頭圖象*/ 
putimage(4,4,rar,XOR_PUT); /*消去光標箭頭圖象*/ 
return 0; 

/*按鍵函數*/ 
int specialkey(void) 

int key; 
while(bioskey(1)==0); /*等待鍵盤輸入*/ 
key=bioskey(0); /*鍵盤輸入*/ 
key=key&0xff? key&0xff:key>>8; /*只取特殊鍵的掃描值,其余為0*/ 
return(key); /*返回鍵值*/ 
}


查看完整回答
反對 回復 2023-04-26
?
阿晨1998

TA貢獻2037條經驗 獲得超6個贊

純C語言,沒有圖形界面的,要做出圖形界面,得依靠系統的API,如MFC、WIN32 API、QT、等

查看完整回答
反對 回復 2023-04-26
  • 2 回答
  • 0 關注
  • 213 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號