Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Zad29 {
- public static double poleWielokata(double[][] wspolrzedne){
- double pole = 0.0;
- for(int x = 0; x < wspolrzedne.length-1; x++){
- for(int y = 0; y < wspolrzedne[x].length-1; y++){
- pole += ((wspolrzedne[x][y] * wspolrzedne[x+1][y+1]) - (wspolrzedne[x+1][y] * wspolrzedne[x][y+1]));
- }
- }
- pole += ((wspolrzedne[wspolrzedne.length-1][0] * wspolrzedne[0][1]) - (wspolrzedne[0][0] * wspolrzedne[wspolrzedne.length-1][1]));
- return Math.abs(pole/2);
- }
- public static void main(String[] args) {
- double[][] testowaTablica = {{1.0, 1.0}, {2.0, 6.0}, {5.0, 5.0}, {7.0, 0.0}};
- System.out.println(poleWielokata(testowaTablica));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement