The world’s largest maker of memory chips and smartphones posted better-than-expected net profit for the fourth quarter, but its core semiconductor business weakened sequentially.