Generation

generate functionMon, 23 Jan 2023

how to sort a string

string sort (string s) { int n = s.length(); for (int i = 0; i < n-1; i++) { for (int j = i+1; j < n; j++) { if (s[i] > s[j]) { char temp = s[i]; s[i] = s[j]; s[j] = temp; } } } return s; }

Questions about programming?Chat with your personal AI assistant