2018-09-28 게시 됨C++Least Recently Used구현123456789101112131415161718192021222324#include <iostream>#include <list>using namespace std;int main() { list<int> cache; int item; int cacheSize = 3; //Cache Size int count = 0; //Cache Miss 횟수 while(true){ cin >> item; if(cin.fail()) break; cache.remove(item); if(cache.size() < cacheSize) cache.push_back(item); else{ cout << cache.front() << endl; //교체가 일어난 item 출력 cache.pop_front(); cache.push_back(item); cache++; } } if(count == 0) cout << 0 << endl; //Cache Miss가 0이면 0 출력 return 0;}Least Recently Usedhttp://crazythink.github.io/2018/09/28/LRU/AuthorDaeyoung KimPosted on2018-09-28Updated on2018-09-28Licensed under#C++