Cod sursa(job #261383)
| Utilizator | Data | 18 februarie 2009 10:22:33 | |
|---|---|---|---|
| Problema | Litere | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <stdio.h>
int main()
{
freopen("litere.in","r",stdin);
freopen("litere.out","w",stdout);
int n,i,r=0,j,s=0,sch,t;
char v[10005],x;
scanf("%d",&n);
while (scanf("%c",&x) != EOF)
v[++r]=x;
do
{
sch=0;
for (i=2; i<=n; i++)
if (v[i]>v[i+1])
{
t=v[i];
v[i]=v[i+1];
v[i+1]=t;
sch=1;
s++;
}
}
while(sch);
printf("%d",s);
return 0;
}