글
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | package Java1; import java.util.Scanner; class Point{ int x; Point pt; int num; Point(int num){ this.num = num; x = (int)(Math.random()*10%5); if(num>0) pt = new Point(num-1, x+1); } Point(int num, int x){ this.x = x; if(num>0) pt = new Point(num-1, x+1); } Point Delete_pt(Point Ori, Point Current){ Point pOld = null; Point pNew = Ori; for( ; pNew!=null; pNew = pNew.pt){ if(Current.equals(pNew)){ if(pOld==null) { Ori=Ori.pt; break; } pOld.pt = pOld.pt.pt; break; } pOld = pNew; } return Ori; } Point findLoc(Point pt, int value){ Point Loc = pt; Point pTemp = pt; for( ; pTemp!=null; pTemp = pTemp.pt){ if(pTemp.x == value) return Loc; else Loc=Loc.pt; } return null; } } public class DotCom{ public static void main(String[] args) { Point pt = new Point(2); Point temp_pt = pt; for(int i=0; i<3; i++,temp_pt=temp_pt.pt){ System.out.println(temp_pt.x); //값 표시 } Scanner s = new Scanner(System.in); int Loc ; int hit=0; while(hit!=3){ Loc = Integer.parseInt(s.next()); if(pt.findLoc(pt, Loc)!=null){ pt = pt.Delete_pt(pt, pt.findLoc(pt, Loc)); System.out.println("hit"); hit++; }else{ System.out.println("miss"); } } System.out.println("kill"); } } /* class Grid{ boolean[][] grid = new boolean[7][7]; boolean rotate(){ int temp = (int)Math.random()*10; if(temp<5){return false;} else{ return true;} } void check_position(Point ori_pt){ } Point getPt(Point pt, int numofelements){ if(pt == null){ pt = new Point(); pt.x = (int) Math.random()*10%7; pt.y = (int) Math.random()*10%7; Point.count++; pt.next = getPt(pt, numofelements); return pt; }else{ if(Point.count!=numofelements-1){ Point pNew = new Point(); return getPt(); } } } void setDotcom(){ Point p = new Point(); } } class Point{ int x, y; static int count; Point left, right; Point next; } class Input{ String key_value; void get_key_value(Point p){ Scanner s = new Scanner(System.in); while(true){ key_value = s.next(); if(key_value.length()!=2){ System.out.println("잘못입력하셨습니다. 다시입력하세요"); }else{ break; } } s.close(); key_value = key_value.toUpperCase(); p.x = Integer.parseInt(key_value.substring(1, 2)); switch(key_value.substring(0, 1)){ case "A": p.y = 0; case "B": p.y = 1; case "C": p.y = 2; case "D": p.y = 3; case "E": p.y = 4; case "F": p.y = 5; case "G": p.y = 6; } } } public class Dotcom { public static void main(String[] args) { Input In = new Input(); Point p = new Point(); In.get_key_value(p); } } */ |