Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc
Bàn luận
******************** * * * * * * * * ********************
Mẫu sao hình chữ nhật rỗng:
- Nhiệm vụ được in dưới mô hình rỗng của kích thước đã cho. & Nbsp; & nbsp;
- Giải thích: & nbsp; & nbsp;
for [i = 1; i < = rows; i++]
- Số đầu vào của các hàng và cột.
for [j = 1; j < = columns; j++]
- Cho các hàng hình chữ nhật chạy vòng ngoài từ 1 đến các hàng. & Nbsp; & nbsp;
- Cho cột hình chữ nhật chạy vòng bên trong từ 1 đến cột. & Nbsp; & nbsp;
C++
#include
In ngôi sao cho hàng đầu tiên hoặc cuối cùng hoặc cho cột đầu tiên hoặc cuối cùng, nếu không thì in không gian trống.
Sau khi in tất cả các cột của một hàng, in dòng mới sau vòng lặp bên trong.
for [i = 1; i < = rows; i++]7
using
namespace
for [i = 1; i < = rows; i++]0
for [i = 1; i < = rows; i++]1
for [i = 1; i < = rows; i++]2
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]4
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]6
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]3
for [j = 1; j < = columns; j++]0
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]3
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************5
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************7
******************** * * * * * * * * ********************8
******************** * * * * * * * * ********************9
******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********1
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************7
******** * * * * * * * * * * * * ********4
******** * * * * * * * * * * * * ********5
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********9
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]8
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
******************** * * * * * * * * ********************3
for [i = 1; i < = rows; i++]8
******** ** ** * * * * * ** * * ** * * * * * ** ** ********0
for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N4
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]
8for [i = 1; i < = rows; i++]
3 if i == 1 or i == N or j == 1 or j == N
8
******** ** ** * * * * * ** * * ** * * * * * ** ** ********5
Sau khi in tất cả các cột của một hàng, in dòng mới sau vòng lặp bên trong.
for [i = 1; i < = rows; i++]7
using
namespace
for [i = 1; i < = rows; i++]0
for [i = 1; i < = rows; i++]1
for [i = 1; i < = rows; i++]2
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]4
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]6
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]3
for [j = 1; j < = columns; j++]0
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]3
******************** * * * * * * * * ********************4
namespace
0namespace
1******************** * * * * * * * * ********************8
namespace
3******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********1
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]8
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
namespace
0namespace
1for [i = 1; i < = rows; i++]06
for [i = 1; i < = rows; i++]07
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]8
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
******************** * * * * * * * * ********************3
for [i = 1; i < = rows; i++]8
******** ** ** * * * * * ** * * ** * * * * * ** ** ********0
for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N4
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]
8for [i = 1; i < = rows; i++]
3 if i == 1 or i == N or j == 1 or j == N
8
for [i = 1; i < = rows; i++]8
******** ** ** * * * * * ** * * ** * * * * * ** ** ********2
******** ** ** * * * * * ** * * ** * * * * * ** ** ********3
C
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
using
8for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************4
namespace
0namespace
1******** * * * * * * * * * * * * ********4
namespace
3Java
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]23
for [i = 1; i < = rows; i++]24
******************** * * * * * * * * ********************1
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]25
for [i = 1; i < = rows; i++]26
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]28
for [i = 1; i < = rows; i++]1
for [i = 1; i < = rows; i++]2
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]4
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]6
for [i = 1; i < = rows; i++]59
for [i = 1; i < = rows; i++]64
******************** * * * * * * * * ********************8
namespace
3******************** * * * * * * * * ********************4
******** * * * * * * * * * * * * ********1
for [i = 1; i < = rows; i++]59
for [i = 1; i < = rows; i++]64
******** * * * * * * * * * * * * ********4
namespace
3******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********7
******************** * * * * * * * * ********************1
for [i = 1; i < = rows; i++]76
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]3
for [j = 1; j < = columns; j++]0
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [i = 1; i < = rows; i++]42
for [i = 1; i < = rows; i++]43
for [i = 1; i < = rows; i++]44
for [j = 1; j < = columns; j++]6
******** ** ** * * * * * ** * * ** * * * * * ** ** ********0
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
Python3
******************** * * * * * * * * ********************1
for [j = 1; j < = columns; j++]2
for [i = 1; i < = rows; i++]49
for [i = 1; i < = rows; i++]43
for [i = 1; i < = rows; i++]51
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************2
for [i = 1; i < = rows; i++]56
for [i = 1; i < = rows; i++]43
for [i = 1; i < = rows; i++]58
for [i = 1; i < = rows; i++]59
for [i = 1; i < = rows; i++]60
for [i = 1; i < = rows; i++]43
for [i = 1; i < = rows; i++]62
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]82
for [i = 1; i < = rows; i++]28
for [i = 1; i < = rows; i++]1
for [i = 1; i < = rows; i++]85
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]90
for [i = 1; i < = rows; i++]91
for [i = 1; i < = rows; i++]92
for [i = 1; i < = rows; i++]93
******** * * * * * * * * * * * * ********5
******************** * * * * * * * * ********************4
for [j = 1; j < = columns; j++]47
namespace
1******************** * * * * * * * * ********************8
for [j = 1; j < = columns; j++]50
for [j = 1; j < = columns; j++]27
for [j = 1; j < = columns; j++]52
for [j = 1; j < = columns; j++]00
for [j = 1; j < = columns; j++]01
******************** * * * * * * * * ********************4
for [j = 1; j < = columns; j++]47
namespace
1******** * * * * * * * * * * * * ********4
for [j = 1; j < = columns; j++]50
for [j = 1; j < = columns; j++]27
for [j = 1; j < = columns; j++]52
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]47
for [j = 1; j < = columns; j++]65
for [i = 1; i < = rows; i++]8
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]04
for [j = 1; j < = columns; j++]05
for [j = 1; j < = columns; j++]06__91
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]09
for [j = 1; j < = columns; j++]10____
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]12
Các
for [j = 1; j < = columns; j++]72
C#
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
for [j = 1; j < = columns; j++]26
for [j = 1; j < = columns; j++]27
for [j = 1; j < = columns; j++]27
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]30
for [j = 1; j < = columns; j++]04__
******************** * * * * * * * * ********************4
for [j = 1; j < = columns; j++]15
for [j = 1; j < = columns; j++]27
for [j = 1; j < = columns; j++]27
for [i = 1; i < = rows; i++]43
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********1
for [j = 1; j < = columns; j++]55
for [j = 1; j < = columns; j++]79
for [i = 1; i < = rows; i++]7
using
namespace
for [i = 1; i < = rows; i++]0
for [i = 1; i < = rows; i++]1
for [i = 1; i < = rows; i++]2
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]4
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]6
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]3
for [j = 1; j < = columns; j++]0
for [j = 1; j < = columns; j++]97
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]3
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************06
******************** * * * * * * * * ********************07
******************** * * * * * * * * ********************08
******************** * * * * * * * * ********************8
namespace
3for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********1
******************** * * * * * * * * ********************07
******************** * * * * * * * * ********************08
******** * * * * * * * * * * * * ********4
namespace
3for [j = 1; j < = columns; j++]97
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]97
******************** * * * * * * * * ********************20
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]79
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]8
for [j = 1; j < = columns; j++]79
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
******************** * * * * * * * * ********************3
for [i = 1; i < = rows; i++]8
******** ** ** * * * * * ** * * ** * * * * * ** ** ********0
for [j = 1; j < = columns; j++]79
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]
3 if i == 1 or i == N or j == 1 or j == N
4
******************** * * * * * * * * ********************40
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N8
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
******************** * * * * * * * * ********************49
******** * * * * * * * * * * * * ********5
for [i = 1; i < = rows; i++]8
******************** * * * * * * * * ********************52
******** * * * * * * * * * * * * ********5
for [i = 1; i < = rows; i++]8
******** ** ** * * * * * ** * * ** * * * * * ** ** ********2
******** ** ** * * * * * ** * * ** * * * * * ** ** ********3
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
C
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
namespace
1******************** * * * * * * * * ********************49
******************** * * * * * * * * ********************84__
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************52
******************** * * * * * * * * ********************84
******************** * * * * * * * * ********************52
******************** * * * * * * * * ********************86
******************** * * * * * * * * ********************45
******************** * * * * * * * * ********************95
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************97
namespace
1******************** * * * * * * * * ********************8
******** * * * * * * * * * * * * ********00
******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********1
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************97
namespace
1******** * * * * * * * * * * * * ********4
******** * * * * * * * * * * * * ********00
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
******************** * * * * * * * * ********************97
namespace
1for [i = 1; i < = rows; i++]06
for [i = 1; i < = rows; i++]07
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********19
******** * * * * * * * * * * * * ********20
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********22
******** * * * * * * * * * * * * ********23
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]2
******** * * * * * * * * * * * * ********19
******************** * * * * * * * * ********************44
******** * * * * * * * * * * * * ********22
for [i = 1; i < = rows; i++]07
******** * * * * * * * * * * * * ********30
JavaScript
******** * * * * * * * * * * * * ********31
for [j = 1; j < = columns; j++]97
******************** * * * * * * * * ********************41
******** * * * * * * * * * * * * ********34
for [j = 1; j < = columns; j++]97
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********38
for [j = 1; j < = columns; j++]0
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]3
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************07
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]8
******************** * * * * * * * * ********************07
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
******** * * * * * * * * * * * * ********52
******** * * * * * * * * * * * * ********53
******** * * * * * * * * * * * * ********54
******************** * * * * * * * * ********************8
for [i = 1; i < = rows; i++]07
******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********1
******************** * * * * * * * * ********************4
******** * * * * * * * * * * * * ********54
******** * * * * * * * * * * * * ********61
for [i = 1; i < = rows; i++]07
******************** * * * * * * * * ********************07
******** * * * * * * * * * * * * ********7
******************** * * * * * * * * ********************07
******** * * * * * * * * * * * * ********54
******** * * * * * * * * * * * * ********67
for [i = 1; i < = rows; i++]07
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]97
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]97
******** * * * * * * * * * * * * ********38
******** * * * * * * * * * * * * ********75
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********77
for [j = 1; j < = columns; j++]97
******** ** ** * * * * * ** * * ** * * * * * ** ** ********0
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********81
Output:
******************** * * * * * * * * ********************
Độ phức tạp về thời gian: O [M * N], trong đó M và N đại diện cho các đầu vào đã cho.AUXILIARITY: O [1], không cần thêm không gian, vì vậy nó là một hằng số.O[m * n], where m and n represents the given inputs.
Auxiliary Space: O[1], no extra space is required, so it is a constant.
Mô hình ngôi sao vuông rỗng:
******** * * * * * * * * * * * * ********
Explanation:
- Số đầu vào của hàng.
- Đối với các hàng, một vòng ngoài từ 1 đến N.
- Cho các cột, một vòng bên trong từ 1 đến n
- Bên trong Ngôi sao in vòng bên trong cho hàng đầu tiên và cuối cùng hoặc cho cột đầu tiên và cuối cùng. Đó là In Star & nbsp; & nbsp;
if i == 1 or i == N or j == 1 or j == N
- nếu không thì in không gian.
- Sau khi in tất cả các cột của một hàng, in một dòng trống sau vòng lặp bên trong. & Nbsp; & nbsp;
C++
#include
using
namespace
for [i = 1; i < = rows; i++]0
for [i = 1; i < = rows; i++]1
******** * * * * * * * * * * * * ********87
for [i = 1; i < = rows; i++]3
******** * * * * * * * * * * * * ********89
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]3
for [j = 1; j < = columns; j++]0
for [i = 1; i < = rows; i++]8
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]3
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
if i == 1 or i == N or j == 1 or j == N01
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
if i == 1 or i == N or j == 1 or j == N06
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************7
******************** * * * * * * * * ********************8
if i == 1 or i == N or j == 1 or j == N10
******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********1
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************7
******** * * * * * * * * * * * * ********4
if i == 1 or i == N or j == 1 or j == N10
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
******************** * * * * * * * * ********************7
for [i = 1; i < = rows; i++]06
******** * * * * * * * * * * * * ********5
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N4
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N31
for [i = 1; i < = rows; i++]8
if i == 1 or i == N or j == 1 or j == N33
for [i = 1; i < = rows; i++]8
******** ** ** * * * * * ** * * ** * * * * * ** ** ********2
******** ** ** * * * * * ** * * ** * * * * * ** ** ********3
******** * * * * * * * * * * * * ********7
C
******** ** ** * * * * * ** * * ** * * * * * ** ** ********5
for [i = 1; i < = rows; i++]1
******** * * * * * * * * * * * * ********87
for [i = 1; i < = rows; i++]3
******** * * * * * * * * * * * * ********89
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]3
for [j = 1; j < = columns; j++]0
for [i = 1; i < = rows; i++]8
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]3
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
if i == 1 or i == N or j == 1 or j == N01
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
if i == 1 or i == N or j == 1 or j == N06
******************** * * * * * * * * ********************4
namespace
0namespace
1******************** * * * * * * * * ********************8
namespace
3for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N4
******************** * * * * * * * * ********************4
namespace
0namespace
1******** * * * * * * * * * * * * ********4
namespace
3for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
namespace
0namespace
1for [i = 1; i < = rows; i++]06
for [i = 1; i < = rows; i++]07
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N4
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N31
for [i = 1; i < = rows; i++]8
if i == 1 or i == N or j == 1 or j == N33
for [i = 1; i < = rows; i++]8
******** ** ** * * * * * ** * * ** * * * * * ** ** ********2
******** ** ** * * * * * ** * * ** * * * * * ** ** ********3
******** * * * * * * * * * * * * ********7
C
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
if i == 1 or i == N or j == 1 or j == N59
________ 31 ________ 41 & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;
Java
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]23
for [i = 1; i < = rows; i++]24
for [i = 1; i < = rows; i++]25
for [i = 1; i < = rows; i++]26
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]28
for [i = 1; i < = rows; i++]1
******** * * * * * * * * * * * * ********87
for [i = 1; i < = rows; i++]3
******** * * * * * * * * * * * * ********89
******************** * * * * * * * * ********************1
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]3
for [j = 1; j < = columns; j++]0
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [i = 1; i < = rows; i++]42
for [i = 1; i < = rows; i++]43
for [i = 1; i < = rows; i++]44
for [i = 1; i < = rows; i++]59
for [i = 1; i < = rows; i++]64
******************** * * * * * * * * ********************8
namespace
3******************** * * * * * * * * ********************4
******** * * * * * * * * * * * * ********1
for [i = 1; i < = rows; i++]59
for [i = 1; i < = rows; i++]64
******** * * * * * * * * * * * * ********4
namespace
3******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********7
******************** * * * * * * * * ********************1
for [i = 1; i < = rows; i++]76
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
******************** * * * * * * * * ********************1
for [j = 1; j < = columns; j++]2
for [i = 1; i < = rows; i++]49
for [i = 1; i < = rows; i++]43
******** ** ** * * * * * ** * * ** * * * * * ** ** ********20
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************2
for [i = 1; i < = rows; i++]56
for [i = 1; i < = rows; i++]43
for [i = 1; i < = rows; i++]58
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]59
for [i = 1; i < = rows; i++]60
for [i = 1; i < = rows; i++]43
******** ** ** * * * * * ** * * ** * * * * * ** ** ********31
for [j = 1; j < = columns; j++]6
if i == 1 or i == N or j == 1 or j == N33
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
Python3
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]82
for [i = 1; i < = rows; i++]28
for [i = 1; i < = rows; i++]1
for [i = 1; i < = rows; i++]85
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]3
for [i = 1; i < = rows; i++]90
******** ** ** * * * * * ** * * ** * * * * * ** ** ********60
******** * * * * * * * * * * * * ********5
for [j = 1; j < = columns; j++]00
******** ** ** * * * * * ** * * ** * * * * * ** ** ********68
for [i = 1; i < = rows; i++]8
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]04
for [j = 1; j < = columns; j++]05
for [j = 1; j < = columns; j++]06__91
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]09
for [j = 1; j < = columns; j++]10____
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]12
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]15
for [j = 1; j < = columns; j++]05
for [j = 1; j < = columns; j++]06____91
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]09
for [j = 1; j < = columns; j++]10
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]12
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
for [j = 1; j < = columns; j++]26
for [j = 1; j < = columns; j++]27
for [j = 1; j < = columns; j++]27
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]30
for [j = 1; j < = columns; j++]04__
******************** * * * * * * * * ********************4
for [j = 1; j < = columns; j++]15
for [j = 1; j < = columns; j++]27
for [j = 1; j < = columns; j++]27
for [i = 1; i < = rows; i++]43
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]47
for [j = 1; j < = columns; j++]65
******************** * * * * * * * * ********************4
for [j = 1; j < = columns; j++]47
namespace
1******************** * * * * * * * * ********************8
#include
17for [j = 1; j < = columns; j++]27
for [j = 1; j < = columns; j++]52
#include
36
C#
using
for [j = 1; j < = columns; j++]74
for [i = 1; i < = rows; i++]25
for [i = 1; i < = rows; i++]26
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]28
for [i = 1; i < = rows; i++]1
#include
44for [i = 1; i < = rows; i++]3
******** * * * * * * * * * * * * ********89
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]3
for [j = 1; j < = columns; j++]0
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]3
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
for [j = 1; j < = columns; j++]2
if i == 1 or i == N or j == 1 or j == N01
******************** * * * * * * * * ********************1
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************2
******************** * * * * * * * * ********************3
for [i = 1; i < = rows; i++]59
#include
66for [i = 1; i < = rows; i++]59
#include
68for [i = 1; i < = rows; i++]59
******************** * * * * * * * * ********************08
******************** * * * * * * * * ********************8
******** * * * * * * * * * * * * ********00
******************** * * * * * * * * ********************4
******** * * * * * * * * * * * * ********1
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************08
******** * * * * * * * * * * * * ********4
******** * * * * * * * * * * * * ********00
******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************20
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]82
for [i = 1; i < = rows; i++]28
for [i = 1; i < = rows; i++]1
******************** * * * * * * * * ********************29
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]3
if i == 1 or i == N or j == 1 or j == N31
for [j = 1; j < = columns; j++]6
#include
98for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
PHP
******************** * * * * * * * * ********************40
******************** * * * * * * * * ********************41
#include
44******************** * * * * * * * * ********************43
******************** * * * * * * * * ********************46
for [i = 1; i < = rows; i++]7
for [i = 1; i < = rows; i++]8
******************** * * * * * * * * ********************49
******** * * * * * * * * * * * * ********5
for [i = 1; i < = rows; i++]8
******************** * * * * * * * * ********************52
******** * * * * * * * * * * * * ********5
for [i = 1; i < = rows; i++]8
for [j = 1; j < = columns; j++]2
namespace
1******************** * * * * * * * * ********************49
******************** * * * * * * * * ********************58
******************** * * * * * * * * ********************49
******************** * * * * * * * * ********************60
******************** * * * * * * * * ********************43
******************** * * * * * * * * ********************62
******************** * * * * * * * * ********************49
******************** * * * * * * * * ********************64
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
namespace
1******************** * * * * * * * * ********************52
******************** * * * * * * * * ********************58__
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
******************** * * * * * * * * ********************2
namespace
1******************** * * * * * * * * ********************49
Is
using
65
******************** * * * * * * * * ********************49
using
67******************** * * * * * * * * ********************4
using
69******************** * * * * * * * * ********************8
******** * * * * * * * * * * * * ********00
******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********1
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************97
******** * * * * * * * * * * * * ********4
using
77for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [j = 1; j < = columns; j++]6
******************** * * * * * * * * ********************97
for [i = 1; i < = rows; i++]06
******** * * * * * * * * * * * * ********5
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********19
using
89for [i = 1; i < = rows; i++]8
#include
44******** * * * * * * * * * * * * ********19
for [i = 1; i < = rows; i++]07
******** * * * * * * * * * * * * ********30
JavaScript
using
95
for [i = 1; i < = rows; i++]8
******************** * * * * * * * * ********************41
using
98for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]7
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********38
for [j = 1; j < = columns; j++]0
for [j = 1; j < = columns; j++]6
for [j = 1; j < = columns; j++]2
for [j = 1; j < = columns; j++]3
for [j = 1; j < = columns; j++]6
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************1
for [j = 1; j < = columns; j++]2
if i == 1 or i == N or j == 1 or j == N01
******************** * * * * * * * * ********************1
for [i = 1; i < = rows; i++]7
******************** * * * * * * * * ********************4
******************** * * * * * * * * ********************2
******************** * * * * * * * * ********************3
for [i = 1; i < = rows; i++]59
namespace
18for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
******************** * * * * * * * * ********************4
******** * * * * * * * * * * * * ********1
for [i = 1; i < = rows; i++]59
******** * * * * * * * * * * * * ********54
******** * * * * * * * * * * * * ********4
namespace
3******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********7
******************** * * * * * * * * ********************1
******** * * * * * * * * * * * * ********54
for [i = 1; i < = rows; i++]06
for [i = 1; i < = rows; i++]07
for [j = 1; j < = columns; j++]6
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]8
******** * * * * * * * * * * * * ********7
for [i = 1; i < = rows; i++]8
for [i = 1; i < = rows; i++]82
for [i = 1; i < = rows; i++]28
for [i = 1; i < = rows; i++]1
******************** * * * * * * * * ********************29
for [j = 1; j < = columns; j++]6
if i == 1 or i == N or j == 1 or j == N33
Output:
******** ** ** * * * * * ** * * ** * * * * * ** ** ********
for [j = 1; j < = columns; j++]
6for [i = 1; i < = rows; i++]
3 if i == 1 or i == N or j == 1 or j == N
31O[n2], where n represents the given input.
Auxiliary Space: O[1], no extra space
is required, so it is a constant.