第1个回答 2007-07-20
你确认ACCESS可以编程吗?
//vc 6.0
#include <stdio.h>
void main()
{
int i=0;
float fSum=0;
for(i=1;i<=100;i++)
{
fSum+=(1.0/i);
}
printf("1+1/2+1/3+...+1/100=%f\r\n",fSum);
}
第2个回答 2007-07-20
'''vb6.0
''-------------
Private Sub Command1_Click()
Dim i, j, k, p As Integer
j = 100
For i = 1 To j
If j Mod 2 = 0 Then
p = 1
Else
p = -1
End If
k = k + p * (1 / i)
Next i
Print k
End Sub本回答被提问者采纳
第3个回答 2007-07-20
public class Calculate {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String opr = "+";
int n = 100;
double sum = 0;
for( float i = 1; i <= n; i++ ){
if( opr.equals("+")){
sum += 1 / i;
opr = "-";
}else{
sum -= 1 / i;
opr = "+";
}
}
System.out.println(sum);
}
}