1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream> using namespace std; int main() { int n; cin >> n; int sum = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { if (i % j == 0) sum += j; } } cout << sum << endl; return 0; }
0 of 5 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 5 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0) 0 Essay(s) Pending (Possible Point(s): 0)
6)该程序的时间复杂度为O(n²)。( )
7)当输入n=3时,输出为10。( )
8)内层循环次数随i增大而增加。( )
9)若输入n=0,程序输出0。( )
10)变量sum最终存储的是1到n之间所有整数“约数个数”之和。( )
Username or Email Address
Password
Remember Me