-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcPtester.java
89 lines (83 loc) · 1.84 KB
/
cPtester.java
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
import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;
public class cPtester
{
public static void main(String[] args) throws IOException
{
Scanner sc = new Scanner(new File("coords.txt"));
ArrayList<coordPoints> al = new ArrayList<coordPoints>();
int a = 0;
while(sc.hasNextLine())
{
int x = sc.nextInt();
int y = sc.nextInt();
coordPoints cP = new coordPoints(x,y);
al.add(cP);
a++;
}
System.out.println(a + " coordinate points.");
int sumx = 0;
int sumy = 0;
for(int i = 0; i < al.size(); i++)
{
sumx += al.get(i).getX();
sumy += al.get(i).getY();
}
System.out.println("Sum of all x values: " + sumx);
System.out.println("Sum of all y values: " + sumy);
System.out.println(al);
int minx = al.get(0).getX();
int miny = al.get(0).getY();
int minvalx = 0;
int minvaly = 0;
for(int i = 1; i < al.size(); i++)
{
int x1 = al.get(i).getX();
int y1 = al.get(i).getY();
if(x1 > minx)
{
minx = x1;
minvalx = i;
}
if(y1 > miny)
{
miny = y1;
minvaly = i;
}
}
String arr[][] = new String[al.get(minvaly).getY()+1][al.get(minvalx).getX()];
for(int i = 0; i < arr.length; i++)
{
Arrays.fill(arr[i], "*");
}
String s = "a";
for(int i = 0; i < al.size(); i++)
{
int x = al.get(i).getX();
int y = al.get(i).getY();
arr[arr.length-y-1][x-1] = s;
s = "" + (char)(s.charAt(0)+1);
}
int k = arr.length-1;
int t = 1;
for(int i = 0; i < arr.length; i++)
{
for(int j = 0; j < arr[0].length; j++)
{
if(j == 0)
{
System.out.print(k-- + " ");
}
if(i == arr.length-1)
{
System.out.print(t++ + " ");
continue;
}
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}