rewrite tc3.cpp