Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to sort a string in c++

#include<bits/stdc++.h>
using namespace std;
int main()
{
	srting str; // First, declare a string.
  	sort(str.begin() , str.end()); // Then sort it by using this method. It is much more convenient.
  	cout << str << endl; // Last of all, print out the string.
}
Comment

how to sort a string in c++

#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n-1;i++){
    for(int j=0;j<n-i-1;j++){
      if(s[j]>s[j+1]) swap(s[j],s[j+1]);
    }
  }
    cout<<s<<endl;
  return 0;
}
Comment

how to sort string array in c++

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n - 1; j++)
            if (s[j] > s[j + 1])
                swap(s[j], s[j + 1]);
    for (int i = 0; i < n; i++)
        cout << s[i] << endl;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: C++ Taking Multiple Inputs 
Cpp :: C++ Vector Operation Delete Elements 
Cpp :: array of charcter c++ 
Cpp :: tower of hanoi 
Cpp :: public method 
Cpp :: C++ Vector Operation Change Elements 
Cpp :: Maximum element in a map c++ 
Cpp :: find second largest number in array c++ 
Cpp :: C++ switch..case Statement 
Cpp :: queue in cpp 
Cpp :: bitmap 
Cpp :: Decision Making in C / C++ (if , if..else, Nested if, if-else-if ) 
Cpp :: cpprestsdk send file 
Cpp :: java to puthon converter 
Cpp :: c++ tuple push_back 
Cpp :: pointers in cpp 
Cpp :: COs trigonometric function 
Cpp :: input numbers to int c++ 
Cpp :: how you can add intger value to string in c++ 
Cpp :: glUniform bool 
Cpp :: C++ using a member function of a class to pass parameters to a thread 
Cpp :: Types of Conversions- C++ 
Cpp :: youtube to facebook link converter 
Cpp :: c++ program that put a space in between characters 
Cpp :: integrate sinx 
Cpp :: pagesNumbering C++ 
Cpp :: max of 3 numbers in c++ 
Cpp :: C++ Array With Empty Members 
Cpp :: SDL_BlitSurface 
Cpp :: c++ cout format specifier for correct number of decimal points 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =