Rem 语言:Visual Basic 6.0
Sub Main() '开始
n = Val(InputBox("请输入n=", "输入"))
S = 0 : i = 1
Do
S = S + i
If Not (i < n) Then Exit Do
i = i + 1
Loop
MsgBox S, vbInformation, "输出"
End Sub '结束
#include
void main()
{
int n,j,x=0;
scanf("%d",&n);
for(j=1;j<=n;j++)
{
x += j;
}
printf("%d\n",x);
return ;
}
验证ok!