前几天刚开始对PAT甲级的刷题,首次看到英语的题目,让原本就菜的我更是头秃,但第一题叫了n遍以后满分通过的时候还是蛮爽的,在此仅记录一下该题的个人解题心路,菜鸟记录,技术极低。
Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).
Each input file contains one test case. Each case contains a pair of integers a and b where −106≤a,b≤106. The numbers are separated by a space.
For each test case, you should output the sum of a and b in one line. The sum must be written in the standard format.
-1000000 9
-999,991
加法计算,但是输出格式需分成三个一组,输入和输出的数据范围控制在10e-6~10e6。
首先,加法的计算和数据的范围无需多说,即重点在于输出的分组,开始我以为作为第一题,会是一个近乎没有结构或算法的题目,于是在开始之前以为会是有关键字或某个库中的函数,迟迟不敢下笔而是苦思冥想有没有学过,脑海搜索失败后开始编写这道题。
由于10e6三个一组并没有太多组,所以仅在该题中可以用if语句写,虽然很笨,但有用。
第一次提交: