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

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条回答

  • caozhy 回答这么多问题就耍赖把我的积分一笔勾销了 10月前
    #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 . . .
    

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

    点赞 评论 复制链接分享

为你推荐