formatting source-code for d7af6fdc8c

This commit is contained in:
github-actions
2020-05-29 23:26:30 +00:00
parent edb3d51ec2
commit 7ad1f171c1
176 changed files with 5342 additions and 4288 deletions

View File

@@ -13,40 +13,48 @@
#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();
int m = b.length();
if (n == m) return a < b;
if (n == m)
return a < 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] << " ";
}