finish main part of ex-1.c for grapg.c