Horje
how to sort a string in c++ Code Example
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.
}
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;
}




Cpp

Related
sqrt cpp Code Example sqrt cpp Code Example
how to declare 1-D array in C/C++ Code Example how to declare 1-D array in C/C++ Code Example
arduino notone Code Example arduino notone Code Example
cout char32_t c++ Code Example cout char32_t c++ Code Example
c++ if example Code Example c++ if example Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8