Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. Move To Front
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5. int main() {
  6. ifstream Fin;
  7. ofstream Fout;
  8. Fin.open("mtf.in");
  9. Fout.open("mtf.out");
  10. char c;
  11. int a[26];
  12. for (int i = 1; i <= 26; i++) {
  13. a[i - 1] = i;
  14. }
  15. while (Fin >> c) {
  16. for (int i = 0; i < 26; i++) {
  17. if (a[i] < a[c - 'a']) {
  18. a[i]++;
  19. }
  20. }
  21. Fout << a[c - 'a'] << " ";
  22. a[c - 'a'] = 1;
  23. }
  24. Fin.close();
  25. Fout.close();
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement