Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Calc {
- int z1;
- int z3;
- int z7;
- int z9;
- int p1=-1;
- int p2=-1;
- int p3=-1;
- int p4=-1;
- int p5=-1;
- int res;
- public void add(int next) {
- next = next % 10;
- if(p1 >= 0) {
- if(p1==1) z1++;
- if(p1==3) z3++;
- if(p1==7) z7++;
- if(p1==9) z9++;
- }
- p1 = p2;
- p2 = p3;
- p3 = p4;
- p4 = p5;
- p5 = next;
- if(next==1) res+=z1;
- if(next==3) res+=z7;
- if(next==7) res+=z3;
- if(next==9) res+=z9;
- }
- public int res() {
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement