其實我完全沒甚麼廢話好說的,隻是希望養成一個總結的好習慣。讓自己以後思路更加清晰。
比如說下面的一道來自杭電的ACM-Steps的一道比較簡單的題目,但是為甚麼多次送出都是錯誤,可是不管怎麼調試都是對的,其實是題目沒有好好看。
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3580 Accepted Submission(s): 1466
Problem Description
Each course grade is one of the following five letters: A, B, C, D, and F. (Note that there is no grade E.) The grade A indicates superior achievement , whereas F stands for failure. In order to calculate the GPA, the letter grades
A, B, C, D, and F are assigned the following grade points, respectively: 4, 3, 2, 1, and 0.
Input
The input file will contain data for one or more test cases, one test case per line. On each line there will be one or more upper case letters, separated by blank spaces.
Output
Each line of input will result in exactly one line of output. If all upper case letters on a particular line of input came from the set {A, B, C, D, F} then the output will consist of the GPA, displayed with a precision of two decimal
places. Otherwise, the message "Unknown letter grade in input" will be printed.
Sample Input
Sample Output
Author
2006Rocky Mountain Warmup
Source
HDU “Valentines Day” Open Programming Contest 2009-02-14
Recommend
lcy
這道題其實真的沒有什麼難度,但是輸出格式還是要注意,尤其對于我這樣的低級新手來說
The input file will contain data for one or more test cases, one test case per line. On each line there will be one or more upper case letters,
separated by blank spaces.
這句話真的是一定要好好讀清楚。
是以修正之後最後的代碼應為:
嗯這是第一篇,如有興趣的朋友,也請多指正。