FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
competitive-programming/Sorting/strings_sorting.cpp at master · kothariji/competitive-programming · GitHub
kothariji
/
competitive-programming
Public
Notifications
You must be signed in to change notification settings
Fork
500
Star
704
Code
Issues
1
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
competitive-programming
/
Sorting
/
strings_sorting.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (36 loc) · 665 Bytes
Breadcrumbs
competitive-programming
/
Sorting
/
strings_sorting.cpp
Copy path
File metadata and controls
38 lines (36 loc) · 665 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
26
27
28
29
30
31
32
33
34
35
36
37
38
#
include
<
iostream
>
#
include
<
string
>
#
include
<
algorithm
>
using
namespace
std
;
bool
compare
(string a,string b)
//
comparator defination
{
if
(a.
length
()==b.
length
())
return
a<b;
return
a.
length
()>b.
length
();
}
int
main
()
{
int
n;
cin>>n;
//
taking no. of strings
cin.
get
();
string s[
100
];
for
(
int
i=
0
;i<n;i++)
{
getline
(cin,s[i]);
}
cout<<endl;
//
sorting
sort
(s,s+n);
for
(
int
i=
0
;i<n;i++)
{
cout<<s[i]<<endl;
}
cout<<endl;
//
comparator
sort
(s,s+n,compare);
for
(
int
i=
0
;i<n;i++)
{
cout<<s[i]<<endl;
}
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL