(判断平方数) 问题:给定一个正整数 n,希望判断这个数是否为完全平方数,即存在一个正整数 x,使得 x的平方为 n。
试补全程序。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include<iostream> #include<vector> using namespace std; bool isSquare(int num) { int i = ___①___; int bound = ___②___; for (; i <= bound; ++i) { if (___③___) { return ___④___; } } return___⑤___; } int main() { int n; cin >> n; if (isSquare(n)) { cout << n << " is a square number" << endl; } else { cout << n << " is not a square number" << 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)
① 处应填( )
② 处应填( )
③ 处应填( )
④ 处应填( )
⑤ 处应填( )