mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-04 02:56:40 +08:00
formatting source-code for 153fb7b8a5
This commit is contained in:
@@ -13,14 +13,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
bool NumericSort(std::string a, std::string b)
|
||||
{
|
||||
while (a[0] == '0')
|
||||
{
|
||||
bool NumericSort(std::string a, std::string b) {
|
||||
while (a[0] == '0') {
|
||||
a.erase(a.begin());
|
||||
}
|
||||
while (b[0] == '0')
|
||||
{
|
||||
while (b[0] == '0') {
|
||||
b.erase(b.begin());
|
||||
}
|
||||
int n = a.length();
|
||||
@@ -30,31 +27,27 @@ bool NumericSort(std::string a, std::string b)
|
||||
return n < m;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
int n;
|
||||
std::cout << "Enter number of elements to be sorted Numerically\n";
|
||||
std::cin >> n;
|
||||
|
||||
std::vector<std::string> v(n);
|
||||
std::cout << "Enter the string of Numbers\n";
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for (int i = 0; i < n; i++) {
|
||||
std::cin >> v[i];
|
||||
}
|
||||
|
||||
sort(v.begin(), v.end());
|
||||
std::cout << "Elements sorted normally \n";
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for (int i = 0; i < n; i++) {
|
||||
std::cout << v[i] << " ";
|
||||
}
|
||||
std::cout << "\n";
|
||||
|
||||
std::sort(v.begin(), v.end(), NumericSort);
|
||||
std::cout << "Elements sorted Numerically \n";
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for (int i = 0; i < n; i++) {
|
||||
std::cout << v[i] << " ";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user