about | help | code help+videos | done | prefs |
identity
Write a method named identity that returns a string representation of a two-dimensional array of int. The parameter is the number of rows (the number of columns is the same.) This square matrix should be an identity matrix, with all the elements 0 except the main diagonal, which should be 1's. For example, identity(3) should return {{1,0,0},{0,1,0},{0,0,1}}. Create the array in this method, then use toString() to return the array as a string. You must cut and paste method toString() from the Hint. identity(1) → "{{1}}" identity(2) → "{{1,0},{0,1}}" identity(3) → "{{1,0,0},{0,1,0},{0,0,1}}" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 315 Post-solution available
Copyright Nick Parlante 2017 - privacy