举报
silencewx
算法就是解决问题的步骤或曰过程,其实在题干中就已经写得很清楚了。下面我根据代码简单写下: .begin 0. read in SIN(9 digits, with rightmost digit the LSB digit, index it with 1) 1. double digits at SIN[2],SIN[4], SIN[6] and SIN[8] to get a 4-element int array step1_result 2. sum individual digits of each step1_result element, then sum the 4 result together to get step2_sum; 3. sum digits of SIN at SIN[9], SIN[7], SIN[5],SIN[3] together to get step3_sum 4. plus step3_sum and step2_sum, to get step4_sum 5. if the unit digit of step4_sum is 0, then we set step5_result with 0; or step5_result is set with 10 minus the unit digit of step4_sum. 6. if step5_result == SIN[1], then SIN is a valid number, and according to SIN[9], we can get which region it belongs to by looking up the region table. 7. if step5_result <>SIN[1], then SIN is not a valid number. .end.