-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25b4a4f
commit 5c7edff
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// In this we will be going to learn about the character array | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
char array[100]; | ||
cin >> array ; | ||
|
||
cout << array[2] ; | ||
|
||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// In this we will be printing the array in the spiral order. | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n, m ; | ||
cin >> n >> m ; | ||
int array[n][m] ; | ||
for(int i=0 ; i<n ; i++) | ||
{ | ||
for(int j=0; j<m ; j++) | ||
{ | ||
cin >> array[i][j] ; | ||
} | ||
} | ||
int rs=0; | ||
int re=n-1; | ||
int cs=0; | ||
int ce=m-1; | ||
while(rs<= re && cs <=ce) | ||
{ | ||
for(int i=cs ; i<=ce ; i++) | ||
{ | ||
cout << array[rs][i] << " " ; | ||
} | ||
rs++; | ||
for(int i=rs ; i<=re ; i++) | ||
{ | ||
cout << array[i][ce] << " " ; | ||
} | ||
ce--; | ||
for(int i=ce ; i>=cs ; i--) | ||
{ | ||
cout << array[re][i] << " " ; | ||
} | ||
re--; | ||
for(int i=re ; i>=rs ; i--) | ||
{ | ||
cout << array[i][cs] << " " ; | ||
} | ||
cs++; | ||
} | ||
|
||
|
||
} |
Binary file not shown.