Code of homework3