【隐身守候】
2020-06-01 23:34
采纳率: 100%
浏览 176

c语言初学者,请各位大佬帮忙,谢谢!

编程求1-99的平方和并输出结果。(328350)
Private Sub Form_Click()
Dim i As Integer, s As Single
For i = 1 To 99

  Next i
  FontSize = 12
  FontBold = True
  Print s

End Sub

编程求1到5000之间的能被5整除的前若干个奇数之和,当和大于500时,终止求和,并输出该和
Private Sub Form_Click()
Dim i As Integer, s As Long
FontSize = 14
FontBold = True

If i Mod 2 <> 0 Then s = s + i
If s > 500 Then Exit For
Next i
Print s
End Sub

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • threenewbee 2020-06-02 00:36
    已采纳
    #include <stdio.h>
    int main()
    {
        int sum = 0;
        for (int i = 1; i <= 99; i++)
            sum += i * i;
        printf("%d\n", sum);
        return 0;
    }
    328350
    Press any key to continue . . .
    
    
    #include <stdio.h>
    int main()
    {
        int sum = 0;
        for (int i = 5; i <= 5000; i += 5)
        {
            sum += i;
            if (sum > 500) break;
        }
        printf("%d\n", sum);
        return 0;
    }
    
    525
    Press any key to continue . . .
    

    问题解决的话,请点下采纳

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题