GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Alternating-Characters/AlternatingCharacters.java at master · Java-Example/Alternating-Characters Expand file tree/ Copy pathAlternatingCharacters.javaMore file actions 43 lines (36 loc) · 935 Bytes / Copy pathAlternatingCharacters.javaFile metadata and controls43 lines (36 loc) · 935 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.ArrayList; public class AlternatingCharacters{ static String removeCharAt(String s, int pos) { return s.substring(0, pos) + s.substring(pos + 1); } public static void main(String[] args) { Scanner s=new Scanner(System.in); int no_of_testcase=s.nextInt(); String values=""; int removechars; ArrayList<String> arrlist = new ArrayList<String>(no_of_testcase); for(int i=0;i<no_of_testcase;i++) { values=s.next(); arrlist.add(values); } for(int i=0;i<arrlist.size();i++) { removechars=0; for(int k=0;k<arrlist.get(i).length()-1;k++) { if(arrlist.get(i).charAt(k)==arrlist.get(i).charAt(k+1)) { removeCharAt(arrlist.get(i),k+1); removechars++; } } System.out.println(removechars); } } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |