随便写写
刚进博客园,先练练手(雾
1 import java.io.*; 2 3 public class GetAllPoints { 4 public static void main(String[] args) throws IOException { 5 File file=new File("PointList.txt"); 6 FileWriter writer=new FileWriter(file); 7 BufferedWriter bw=new BufferedWriter(writer); 8 String s=null; 9 int[][] dotlist; 10 int[][] data={{138,86},{143,220},{276,421},{296,434},{424,482},{661,435},{759,343},{815,220},{821,86}}; 11 int[] a={479,141}; 12 for(int i=1;i<=9;i++) { 13 dotlist=dotsOnThePartLine(a,data[i-1],1000); 14 bw.write(i+"Line"+dotlist.length); 15 bw.newLine(); 16 for(int j=0;j<dotlist.length;j++) { 17 bw.write(dotlist[j][0]+" "+dotlist[j][1]); 18 bw.newLine(); 19 } 20 } 21 bw.close(); 22 writer.close(); 23 } 24 public static int[][] dotsOnThePartLine(int[] A,int[] B,int step) { 25 assert A.length==2&&B.length==2:"Not A Dot"; 26 assert !(A[0]==B[0]&&A[1]==B[1]):"Dots are same"; 27 int[] min=new int[2]; 28 if(A[0]==B[0]) { 29 int[][] res=new int[Math.round(Math.abs(B[1]-A[1]))+1][2]; 30 min[1]=Math.min(A[1],B[1]); 31 for(int i=0;i<res.length;i++) { 32 res[i][0]=A[0]; 33 res[i][1]=min[1]+i; 34 } 35 return res; 36 } 37 else if(A[1]==B[1]) { 38 int[][] res=new int[Math.round(Math.abs(B[0]-A[0]))+1][2]; 39 min[0]=Math.min(A[0],B[0]); 40 for(int i=0;i<res.length;i++) { 41 res[i][1]=A[1]; 42 res[i][0]=min[0]+i; 43 } 44 return res; 45 } 46 else { 47 int[][] List=new int[step+1][2]; 48 List[0][0]=A[0]; 49 List[0][1]=A[1]; 50 for(int t=1;t<=step;t++) { 51 List[t][0]=Math.round(A[0]+1.1F*t*(B[0]-A[0])/(float)step); 52 List[t][1]=Math.round(A[1]+1.1F*t*(B[1]-A[1])/(float)step); 53 } 54 int[][] subList=new int[step+1][2]; 55 subList[0][0]=List[0][0]; 56 subList[0][1]=List[0][1]; 57 int now=1; 58 for(int i=1;i<=step;i++) { 59 if((List[i][0]!=subList[now-1][0])||(List[i][1]!=subList[now-1][1])) { 60 subList[now][0]=List[i][0]; 61 subList[now][1]=List[i][1]; 62 now++; 63 } 64 } 65 int[][] res=new int[now][2]; 66 for(int i=0;i<now;i++) { 67 res[i][0]=subList[i][0]; 68 res[i][1]=subList[i][1]; 69 } 70 return res; 71 } 72 } 73 }
随便插了一段代码23333
| Oh what's this | OOOOOOOO | HahahahaHaHhhHKajIIIImWhhfdsafadsa | Jasasads |
| Haha |
Why I can't insert words into the block above?!! (Why I can't see the... (I can see it now |
||
| fsa | |||
| asasa |
2016-10-14 19:53:46
浙公网安备 33010602011771号