"title"  
the reform and opening up of 30 has brought about tremendous changes to China. 2011 China's mobile phone production is about 1.172 billion units a year. Mobile phone has become the basic daily necessities of the people!
Choosing a nice and well-remembered number for a phone may be a wish for many people.
But the source is limited, only supplemented by the method of paid election number.
The purpose of this program is to score according to certain rules based on a given cell phone tail number (4-bit). The rules are as follows:
1. If a hyphen appears, add 5 points regardless of ascending or descending order. For example: 5678,4321 all meet the standard of addition.
2. The first three digits are the same, or the last three digits are the same, plus 3 points. For example: 4888,6665,7777 all meet the standard of adding points.
Note: 7777 because it satisfies this standard two times, so this rule adds 6 points to it.
3.1 points in accordance with AABB or Abab mode. For example: The 2255,3939,7777 all conform to this pattern, so they are all added points.
Note: 7777 because this standard is met two times, so this standard adds 2 points to it.
4. Contains: Any number in the 6,8,9, plus 1 points for each occurrence. 4326,6875,9918, for example, are eligible for the plus points standard. Of these, 6875 were added 2 points; 9918 were added 3 points.
Tail number final score is the sum of each standard's bonus points!
requires the program to receive data from standard input and output results on standard output. The
Input format is: The first line is an integer n (<100), which is the number of input rows below, followed by the 4-bit data of n rows, which is the phone tail number waiting for the calculation of the added points.
For example, enter:
14
3045
...
...
6789
8866
Outputs:
0
0
...
...
8
5
public static void Main (string[] args) {Scanner sc = new Scanner (system.in); int n = sc.nextint (); string[] sa = new String[n]; Loop get all Phones tail number for (int i = 0; i < n; i++) {Sa[i] = Sc.next (); } sc.close (); for (int i = 0; i < n; i++) {System.out.println (HANDLERPN (Sa[i])); }}//rated for each cell phone tail number private static int handlerpn (String s) {int result = 0; char[] cc = S.tochararray (); int[] ic = new Int[cc.length]; for (int i = 0; i < ic.length; i++) {ic[i] = cc[i]-' 0 '; }//1, determine if there is a Boolean LH = true; for (int i = 0; i < ic.length-1; i++) {if (Math.Abs (ic[i+1]-ic[i])! = 1) {LH = false; Break }} if (LH) {result + = 5; }//2, judging if the first three are the same if ((Ic[0]==ic[1]&&ic[1]==ic[2])) {result + = 3; } if ((ic[1)==ic[2]&&ic[2]==ic[3]) {result + = 3; }//3, judging whether it complies with AABB or Abab if (ic[0]==ic[1] && ic[2]==ic[3]) {result + = 1; } if (Ic[0]==ic[2] && ic[1]==ic[3]) {result + = 1; }//4, whether to appear 6, 8, 9 of the number for (int i = 0; i < ic.length; i++) {if (ic[i] = = 6 | | ic[i] ==8 | | ic[i]== 9) {result + = 1; }} return result; }
Import java.util.*;p Ublic class Lanq {//1534 public static void Main (string[] args) {solve (); Check (); } public static void Solve () {Scanner sc = new Scanner (system.in); int test = Sc.nextint (); while (test--> 0) {String ans = sc.next (); int sum=0; char []a=new char[4]; A=ans.tochararray (); if (a[0]+1==a[1]&&a[1]+1==a[2]&&a[2]+1==a[3]) sum+=5; if (a[0]-1==a[1]&&a[1]-1==a[2]&&a[2]-1==a[3]) sum+=5; if (a[0]==a[1]&&a[1]==a[2]) sum+=3; if (a[1]==a[2]&&a[2]==a[3]) sum+=3; if (a[0]==a[1]&&a[2]==a[3]) sum+=1; if (a[0]==a[2]&&a[1]==a[3]) sum+=1; if (a[0]== ' 6 ' | | a[0]== ' 8 ' | | a[0]== ' 9 ') sum+=1; if (a[1]== ' 6 ' | | a[1]== ' 8 ' | | a[1]== ' 9 ') sum+=1; if (a[2]== ' 6 ' | | a[2]== ' 8 ' | | a[2]== ' 9 ') sum+=1; if (a[3]== ' 6 ' | | a[3]== ' 8 ' | | a[3]== ' 9 ') sum+=1; System.out. println (sum); } }
08 Simple deduction: Mobile tail number Rating