Cod sursa(job #2930927)
Utilizator | Data | 29 octombrie 2022 20:52:20 | |
---|---|---|---|
Problema | Litere | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <fstream>
#include <queue>
#include <iostream>
using namespace std;
int n,ct;
bool x;
string s;
int main()
{
ifstream f ("litere.in");
ofstream g ("litere.out");
f>>n;
f>>s;
for (int i=0;i<n;i++)
{
for (int j=i;j<n;j++)
{
if (s[j]>s[j+1])
{
ct++;
swap(s[j],s[j+1]);
}
}
}
g<<ct;
}