Pagini recente » Cod sursa (job #2854403) | Cod sursa (job #852196) | Cod sursa (job #1339331) | Cod sursa (job #1476546) | Cod sursa (job #3194433)
#include <bits/stdc++.h>
using namespace std;
const string FILE_NAME = "litere";
ifstream fin(FILE_NAME + ".in");
ofstream fout(FILE_NAME + ".out");
int main() {
int n, c = 0;
string s;
fin >> n >> s;
bool sortat = true;
do{
sortat = true;
for(int i = 1; i < n; i++){
if(s[i] < s[i - 1]){
swap(s[i], s[i - 1]);
sortat = false;
c++;
}
}
}while(sortat != true);
fout << c;
return 0;
}