Cod sursa(job #554725)

Utilizator bocacristiBoca Nelu Cristian bocacristi Data 15 martie 2011 08:47:13
Problema Litere Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>
using namespace std;

ifstream fin("litere.in");
ofstream fout("litere.out");

char a[10001];
int n;

int main()
{
	fin >> n;
	int pp = 0;
	fin.get();
	fin.getline(a, 10001 );
	
	for ( int i = 0; i < n-1; i++ )
		for ( int j = i+1; j < n; j++ )
			if ( a[i] > a[j] )
			{
				int aux;
				aux = a[j];
				a[j] = a[i];
				a[i] = aux;
				pp++;
			}
	
	fout << pp;
	fin.close();
	fout.close();
	return 0;
}