真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

c語(yǔ)言計(jì)算器程序調(diào)用函數(shù) c語(yǔ)言運(yùn)用調(diào)用函數(shù)的方法實(shí)現(xiàn)簡(jiǎn)易計(jì)算器

c語(yǔ)言計(jì)算器程序設(shè)計(jì)包含加減乘除簡(jiǎn)單的函數(shù)運(yùn)算

實(shí)用計(jì)算器之程序設(shè)計(jì)

創(chuàng)新互聯(lián)主要從事網(wǎng)頁(yè)設(shè)計(jì)、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、wap網(wǎng)站建設(shè)(手機(jī)版網(wǎng)站建設(shè))、成都響應(yīng)式網(wǎng)站建設(shè)公司、程序開(kāi)發(fā)、網(wǎng)站優(yōu)化、微網(wǎng)站、微信平臺(tái)小程序開(kāi)發(fā)等,憑借多年來(lái)在互聯(lián)網(wǎng)的打拼,我們?cè)诨ヂ?lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了豐富的成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、網(wǎng)站設(shè)計(jì)、網(wǎng)絡(luò)營(yíng)銷經(jīng)驗(yàn),集策劃、開(kāi)發(fā)、設(shè)計(jì)、營(yíng)銷、管理等多方位專業(yè)化運(yùn)作于一體。

[摘 要]多用計(jì)算器的構(gòu)思及設(shè)計(jì)代碼

[關(guān)鍵詞]多用計(jì)算器;設(shè)計(jì)

數(shù)值計(jì)算可以說(shuō)是日常最頻繁的工作了,WIN98提供了“計(jì)算器”軟件供用戶使用,該軟件可以處理一般的一步四則運(yùn)算,例如:3+2、5/3等等,但在日常中用戶經(jīng)常遇到多步四則運(yùn)算問(wèn)題,例如:3+4*5-4/2,45*34/2+18*7等等,那么該個(gè)計(jì)算器就無(wú)法勝任了,作者制作了一個(gè)實(shí)用的計(jì)算器,該計(jì)算器新增不少功能:(程序界面如圖)

1.可以實(shí)現(xiàn)連續(xù)的四則運(yùn)算

2.可以實(shí)現(xiàn)輸入式子的顯示

3.可以方便計(jì)算個(gè)人所得稅

4.鼠標(biāo)、鍵盤(pán)均可輸入數(shù)據(jù)

5.操作界面友好

6.擊鍵可發(fā)聲

構(gòu)建該個(gè)計(jì)算器所需研究及解決的核心問(wèn)題有如下幾個(gè):1、連乘求值?2、字符顯示 3、鍵盤(pán)輸入?4、擊鍵發(fā)聲?5、個(gè)人所得稅法規(guī),為了使大家對(duì)程序有更一步認(rèn)識(shí),現(xiàn)將代碼提供給讀者參考:

*定義數(shù)組及窗體變量

Dim number2(0 To 50) As Double

Dim number(0 To 50) As Double

Dim z As Integer

Dim k As Integer, r As Integer

Dim j As Integer

Dim str As String

*調(diào)用名為“playsound”的API函數(shù)

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_FILENAME = H20000?

Private Const SND_ASYNC = H1?

Private Const SND_SYNC = H0

*判斷通用過(guò)程

Sub pianduan(p As String)

r = 0

Dim i As Integer, l As Integer, h As Integer

h = 0

i = 1

If InStr(Trim$(p), "*") 0 Then

k = k + 1

End If

If InStr(Trim$(p), "/") 0 Then

r = r + 1

End If

End Sub

*連乘通用過(guò)程(略)

*各按鈕事件過(guò)程

Private sub Command1_Click(Index As Integer)

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text1.Text = Text1.Text + Command1(Index).Caption

Text2.Text = Text2.Text + Command1(Index).Caption

Text1.SetFocus

End Sub

rivate sub Command10_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

str = Text3.Text

End Sub

Private sub Command11_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text3.Text = str

End Sub

rivate sub Command2_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "+"

z = z + 1

Text1.SetFocus

End Sub

rivate sub Command3_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "-"

Text1.Text = Text1.Text "-"

z = z + 1

Text1.SetFocus

End Sub

Private sub Command4_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text2.Text = Text2.Text + "*"

Text1.Text = Text1.Text + "*"

Text1.SetFocus

End Sub

rivate sub Command5_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text2.Text = Text2 + "/"

Text1.Text = Text1 + "/"

Text1.SetFocus

End Sub

Private sub Command6_Click()

PlaySound App.Path "\sound.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

z = z + 1

Dim dengyu As Double

Dim v As Integer

For v = 0 To 50

dengyu = dengyu + number2(v)

Next v

If dengyu 0 Then

Text3.ForeColor = HFF

Else

Text3.ForeColor = HFF0000

End If

Text3.Text = dengyu

Text1.SetFocus

If Len(Text3.Text) = 14 Then

calcresult.Show

End If

End Sub

rivate sub Command7_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

z = 0: k = 0: r = 0: j = 0

Dim i As Integer

For i = 0 To 50

number(i) = 0

number2(i) = 0

Next i

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.SetFocus

End Sub

rivate sub Command8_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

If Val(Text3.Text) = 0 Then

MsgBox "除數(shù)不能為0!"

Exit Sub

End If

Text3.Text = 1 / Val(Text3.Text)

End Sub

Private sub Command9_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text3.ForeColor = HFF0000

Text3.Text = Val(Text3.Text) * Val(Text3.Text)

End Sub

rivate sub muninternet_Click()

Dim i

i = Shell("C:\Program Files\InternetExplorer\iexplore.exe", vbMaximizedFocus)

End Sub

rivate sub munmp3_Click()

Dim i

i = Shell("C:\Program Files\Windows Media Player\mplayer2", vbNormalNoFocus)

End Sub

Private sub munsm_Click()

Dialog.Show

End Sub

rivate sub muntax_Click()

tax.Show

End Sub

rivate sub munver_Click()

ver.Show

End Sub

rivate sub notepad_Click()

Dim i

i = Shell("c:\windows\notepad", vbNormalFocus)

End Sub

Private sub Text1_KeyPress(KeyAscii As Integer)

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim num As Integer

num = Val(KeyAscii)

If num 47 And num 58 Then

Text1.Text = Text1.Text + CStr(num - 48)

Text2.Text = Text2.Text + CStr(num - 48)

End If

If num = 46 Then

Text1.Text = Text1.Text + "."

Text2.Text = Text2.Text + "."

End If

If KeyAscii = 43 Then

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "+"

z = z + 1

End If

If KeyAscii = 45 Then

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "-"

Text1.Text = Text1.Text "-"

z = z + 1

End If

If KeyAscii = 42 Then

Text2.Text = Text2.Text + "*"

Text1.Text = Text1.Text + "*"

End If

If KeyAscii = 47 Then

Text2.Text = Text2.Text + "/"

Text1.Text = Text1.Text + "/"

End If

If KeyAscii = vbKeyReturn Then

PlaySound App.Path "\sound.wav", 0, SND_SYNC

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

z = z + 1

Dim dengyu As Double

Dim v As Integer

For v = 0 To 50

dengyu = dengyu + number2(v)

Next v

If dengyu 0 Then

Text3.ForeColor = HFF

Else

Text3.ForeColor = HFF0000

End If

Text3.Text = dengyu

End If

If KeyAscii = vbKeyEscape Then

z = 0: k = 0: r = 0: j = 0

Dim i As Integer

For i = 0 To 50

number(i) = 0

number2(i) = 0

Next i

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.SetFocus

End If

If Len(Text3.Text) = 14 Then

calcresult.Show

End If

End Sub

rivate sub Text3_Change()

tax2.Text1 = Text3.Text

End Sub

c語(yǔ)言 如何在main中調(diào)用函數(shù)

是這樣的,C語(yǔ)言在編譯時(shí)候是順序編譯的 ,也就是說(shuō),如果被調(diào)用的函數(shù)是在調(diào)用函數(shù)之前被聲明過(guò),就可以通過(guò)編譯,反之就會(huì)報(bào)錯(cuò)。

你這個(gè)有兩種解決方案,1,在程序最開(kāi)始聲明所有函數(shù) 2,把float jian(float a;float b;)這函數(shù)所有內(nèi)容放到main()前面

使用c語(yǔ)言編程,用函數(shù)實(shí)現(xiàn)一個(gè)計(jì)算器,在主函數(shù)中調(diào)用函數(shù),包括加減乘除,乘方,絕對(duì)值和sin函數(shù)。

#includestdio.h

#includestdlib.h

double jia(double a,double b)

{

return a+b;

}

double jian(double a,double b)

{

return a-b;

}

double cheng(double a,double b)

{

return a*b;

}

double chu(double a,double b)

{

return a/b;

}

double juedui(double a)

{

return a0 ? a : -a;

}

double chengfang(double a,double b)

{

return pow(a,b);

}

double sinx(double a)

{

return sin(a);

}

int main()

{

int m;

double a,b;

while(1)

{

printf("請(qǐng)輸入第一個(gè)操作數(shù):");

scanf("%lf",a);

printf("0、退出\n1、加\n2、減\n3、乘\n4、除\n5、絕對(duì)值\n6、乘方\n7sin、\n請(qǐng)選擇一個(gè):");

scanf("%d",m);

if(1==m || 2==m || 3==m || 4==m || 6==m)

{

printf("請(qǐng)輸入第二個(gè)操作數(shù):");

scanf("%lf",b);

}

switch(m)

{

case 0:

exit(0);

break;

case 1:

printf("%lf+%lf=%lf\n",a,b,jia(a,b));

break;

case 2:

printf("%lf-%lf=%lf\n",a,b,jian(a,b));

break;

case 3:

printf("%lf*%lf=%lf\n",a,b,cheng(a,b));

break;

case 4:

if(0.0==b)

{

printf("除數(shù)不能為0。\n");

}

else

{

printf("%lf/%lf=%lf\n",a,b,chu(a,b));

}

break;

case 5:

printf("|%lf|=%lf\n",a,juedui(a));

break;

case 6:

printf("%lf的%lf方=%lf\n",a,b,chengfang(a,b));

break;

case 7:

printf("sin(%lf)=%lf\n",a,sinx(a));

break;

default:

printf("無(wú)法處理的命令。\n");

break;

}

}

system("PAUSE");

return EXIT_SUCCESS;

}

計(jì)算機(jī)c語(yǔ)言中函數(shù)之間如何調(diào)用

C語(yǔ)言都是先定義后使用的

通過(guò)函數(shù)名調(diào)用如:

double

sum(double

x,double

y)

{

double

z;

z=x+y;

retun(z);

}

main()

{

double

h;

double

a,b;

h=sum(a,b);

}


當(dāng)前名稱:c語(yǔ)言計(jì)算器程序調(diào)用函數(shù) c語(yǔ)言運(yùn)用調(diào)用函數(shù)的方法實(shí)現(xiàn)簡(jiǎn)易計(jì)算器
標(biāo)題網(wǎng)址:http://weahome.cn/article/docjgie.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部