1-2+3-4+5-…+99-100的值。VB程序的代码是怎样的?

VB程序的代码!请大家帮帮忙!谢谢大家了!
2024-11-18 10:50:16
推荐回答(4个)
回答(1):

看到都觉得羞耻,这么多改盯历人乱发核搜程序来骗分,丢脸,以下则伍是正确答案
Private Sub Form_Click()
Me.Cls
Dim i, Sum As Single
For i = 1 To 100
Sum = Sum + i * (-1) ^ (i - 1)
Next i
Print Sum
End Sub

回答(2):

VB的:
Private Function js()
Dim s, i As Integer
For i = 1 To 100 Step 1
If i Mod 2 = 0 Then
s = s - i
Else
s = s + i
End If
Next
js = s
End Function

回答(3):

main()
{
int s=0;
for(int i=1;i<101;i++)
{
if(i%2==0)
i=-i;
s+=i;
}
}

回答(4):

dim s%塌灶亏团神辩铅
FH=1
for i =1 to 100 step 1
s=s+i
FH = -FH
Next i