Please format your code using [coe] tags as what you have posted is almost unreadable. use Go Advanced, select code then click '#'.

Help you about what? You haven't asked a question! If you want to convert this c++ code to c (why??) then as a starter for 10 you need to replace all references to the c++ classes (cin, cout, ifstream etc) with appropriate code using just the c library functions (printf, fread etc).