当前位置: 代码迷 >> C语言 >> 计算机二级C考完了
  详细解决方案

计算机二级C考完了

热度:237   发布时间:2006-05-20 21:37:00.0
哦 看了你做的了 用VB做的 不错 但我不知道 用C 做出来的效果怎么样

有代码么 给大家看看 谢谢喽
----------------解决方案--------------------------------------------------------
以下是引用海蓝啸在2006-4-4 22:19:00的发言:
呵呵。。应该可以过的。。。。。
不过我有个不明白的。。。。
请各位大虾指点一下。。

改错题有个if(t>num)
应该改为t的绝对值。而不是t
所以我就改成了if(fabs(t)>num)
但是运行得不到预期结果。。。。
然后我看了一下main函数的头文件中包括了math.h了啊
但是不知道为什么不行。。。
然后我只好改成if(t>num||t<-m)
然后运行对了。。。
我就搞不懂了,这两个不是等价的吗?
为什么不行啊?
晕倒

double类型用FABS
int 类型用ABS
----------------解决方案--------------------------------------------------------

#include<stdio.h>
#include<math.h>

void main()
{
int i = -3, a;
float j = -2, b;

a = fabs (i);
b = abs (j);

printf("%d, %f\n", a, b);

getch ();
}

但这样也能得到正确结果呀.


----------------解决方案--------------------------------------------------------
回复:(xsimon)#include<stdio.h>#include<...
以下是引用xsimon在2006-5-22 10:23:00的发言:

#include<stdio.h>
#include<math.h>

void main()
{
int i = -3, a;
float j = -2, b; //本行改成 float j = -2.5, b; 您再试试!

a = fabs (i); //此处成功是fabs()形参兼容int型的结果。
b = abs (j); //此处侥幸成功是因为(-2)无小数部分。

printf("%d, %f\n", a, b);

getch ();
}

但这样也能得到正确结果呀.错啦!!!


----------------解决方案--------------------------------------------------------
斑竹英明。。。PFPF
----------------解决方案--------------------------------------------------------

以下是引用龙轩v亚风在2006-5-20 21:37:00的发言:
哦 看了你做的了 用VB做的 不错 但我不知道 用C 做出来的效果怎么样

有代码么 给大家看看 谢谢喽

好长时间没来过了, 代码在学校,回学校再贴上来把。。。。。
----------------解决方案--------------------------------------------------------

Option Explicit
Dim zifu1 As String, zifu2 As String, linshizifu As String * 1, anniu%, num1#, num2#, result#
Private Sub Command1_Click()
linshizifu = Command1.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command10_Click()
linshizifu = Command10.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command11_Click()
num1 = Val(zifu1)
num2 = Val(zifu2)
Select Case anniu
Case 1
result = num1 + num2
Picture1.Print "=" & result
Case 2
result = num1 - num2
Picture1.Print "=" & result
Case 3
result = num1 * num2
Picture1.Print "=" & result
Case 4
If num2 = 0 Then
Picture1.Print " 输入错误.被除数不能为零"
Else
result = num1 / num2
Picture1.Print "=" & result
End If
Case 5
result = num1 ^ num2
Picture1.Print "=" & result
End Select

End Sub

Private Sub Command12_Click()
linshizifu = Command12.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command13_Click()
Picture1.Print Command13.Caption;
anniu = 1
End Sub

Private Sub Command14_Click()
Picture1.Print Command14.Caption;
anniu = 4
End Sub

Private Sub Command15_Click()
Picture1.Print Command15.Caption;
anniu = 3
End Sub

Private Sub Command16_Click()
Picture1.Print Command16.Caption;
anniu = 2
End Sub

Private Sub Command17_Click()
zifu1 = ""
zifu2 = ""
anniu = 0
Picture1.Cls
End Sub

Private Sub Command18_Click()
Dim a%
a = Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE", 1)
End Sub

Private Sub Command19_Click()
Dim a%
a = Shell("regedit.exe", 1)
End Sub

Private Sub Command2_Click()
linshizifu = Command2.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command20_Click()
Dim a%
a = Shell("C:\Program Files\Outlook Express\msimn.exe", 1)
End Sub

Private Sub Command21_Click()
Dim a%
a = Shell("C:\WINDOWS\explorer.exe", 1)
End Sub

Private Sub Command22_Click()
Dim a%
a = Shell("C:\Program Files\Windows Media Player\wmplayer.exe", 1)
End Sub

Private Sub Command23_Click()
Dim a%
a = Shell("C:\WINDOWS\system32\taskmgr.exe", 1)
End Sub

Private Sub Command24_Click()
Dim a%
a = Shell("C:\WINDOWS\system32\notepad.exe", 1)
End Sub

Private Sub Command25_Click()
Dim a%
a = Shell("C:\WINDOWS\pchealth\helpctr\binaries\msconfig.exe", 1)
End Sub

Private Sub Command26_Click()
linshizifu = Command26.Caption
Picture1.Print linshizifu;
anniu = 5
End Sub

Private Sub Command27_Click()
num1 = Val(zifu1)
If num1 >= 0 Then
result = Sqr(num1)
Picture1.Print "开方=" & result
Else
Picture1.Print " 负数不能开方"
End If
End Sub

Private Sub Command28_Click()
linshizifu = "-"
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command3_Click()
linshizifu = Command3.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command4_Click()
linshizifu = Command4.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command5_Click()
linshizifu = Command5.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command6_Click()
linshizifu = Command6.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command7_Click()
linshizifu = Command7.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command8_Click()
linshizifu = Command8.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Command9_Click()
linshizifu = Command9.Caption
Picture1.Print linshizifu;
If anniu = 0 Then
zifu1 = zifu1 & linshizifu
Else
zifu2 = zifu2 & linshizifu
End If
End Sub

Private Sub Form_Load()
anniu = 0
End Sub

Private Sub 打开cmd_Click()
Dim a%
a = Shell("cmd.exe", 1)
End Sub
――――――――――――――――――――――――――――――――――――――――――――


[此贴子已经被作者于2006-12-31 13:49:15编辑过]


----------------解决方案--------------------------------------------------------
高手,偶像呢
----------------解决方案--------------------------------------------------------
不是23号考没?

奇怪
----------------解决方案--------------------------------------------------------
楼主真厉害,有时间教我几招,
----------------解决方案--------------------------------------------------------
  相关解决方案