Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Move To Front
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- ifstream Fin;
- ofstream Fout;
- Fin.open("mtf.in");
- Fout.open("mtf.out");
- char c;
- int a[26];
- for (int i = 1; i <= 26; i++) {
- a[i - 1] = i;
- }
- while (Fin >> c) {
- for (int i = 0; i < 26; i++) {
- if (a[i] < a[c - 'a']) {
- a[i]++;
- }
- }
- Fout << a[c - 'a'] << " ";
- a[c - 'a'] = 1;
- }
- Fin.close();
- Fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement