Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- string s;
- int l;
- void selection_sort()
- {
- for (int i = 0;i < 15;i++){
- int t = i;
- for (int j = i+1;j < l;j++){
- if (s[t] > s[j])t = j;
- }
- if (i != t){
- char ch = s[t];
- s[t] = s[i];
- s[i] = ch;
- }
- }
- }
- int main()
- {
- int t, result = 0;
- scanf("%d", &t);
- string test_s;
- char ch = 'a';
- for (int i = 0;i < 26;i++, ch++){
- test_s[i] = ch;
- }
- while (t--){
- cin >> s;
- l = s.length();
- selection_sort();
- for (int i = 0;i < 15;i++){
- int carry = 1;
- for (int j = 0;s[i] != test_s[j];j++)carry++;
- result += carry;
- }
- }
- printf("%d\n", result);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement