Problem 44399. 二乗になっている数を見つけよう
ある数のベクトルが与えられた場合、そのベクトルの要素の一つが他の要素の二乗であれば true を返し、それ以外の場合は false を返すようなコードを書いてみましょう。
例:
入力が a = [2 3 4] のとき、 出力 b は true になります。
2の2乗は4であり、ベクトル内に2と4の両方が含まれているため、出力は true になります。
- (英語版) Problem 23. Finding Perfect Squares https://www.mathworks.com/matlabcentral/cody/problems/23-finding-perfect-squares/solutions/1330236
Solution Stats
Problem Comments
-
2 Comments
David Verrelli
on 11 Nov 2017
This appears to be duplicating an error in the original Problem: according to the problem specification, having an input of [1] should yield a result of "false", as there is no OTHER element to compare the 1 to! You can easily fix this inconsistency by either --- changing your problem specification (mention that you can compare to all vector elements, not just the 'other' elements) or --- by changing the correct result to "false" in your Test Suite.
David Verrelli
on 11 Nov 2017
Please check comments made about the original Problem to avoid duplicating errors or inconsistencies.
Solution Comments
Show commentsGroup

Cody Problems in Japanese
- 16 Problems
- 272 Finishers
- ベクトルのスケーリング
- 二つのベクトルの要素ごとの積の平均を計算しよう
- 2倍してみよう - ここからスタート!
- ベクトル [1 2 3 4 5 6 7 8 9 10] の作成
- サイコロを作ろう
- チェッカーボードを作ろう
- ベクトルの値が増加しているかを調べよう
- 二乗になっている数を見つけよう
- 二つのベクトルの要素ごとの積の平均を計算しよう
- 行列内の素数の平均をとろう
- ゼロでない要素が一番多い行を探そう
- 特定の値がベクトル内に含まれているかを確認するコードを書こう
- NaN (欠損値) が含まれている行を削除しよう
- テレビのサイズを求めてみよう
- 英語の文章内の母音を取り除くコードを書きましょう。
- 対称で、n*2n のサイズの行列を作成しましょう
- 文字列の最初と最後の文字だけ抜き出しましょう。
Problem Recent Solvers326
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!