Code get segmentation fault

Please format your code before posting.