-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiziSatirSutunOrtUzaklikYeniDizi.java
105 lines (89 loc) · 2.44 KB
/
DiziSatirSutunOrtUzaklikYeniDizi.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import java.text.DecimalFormat;
import java.util.Scanner;
public class DiziSatirSutunOrtUzaklikNewDizi {
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("#.#");
int satir, sutun;
System.out.print("Satir sayisi : ");
satir = scanner.nextInt();
System.out.print("Sutun sayisi : ");
sutun = scanner.nextInt();
int[][] dizi = new int[satir][sutun];
for(int i=0; i<satir; i++)
{
for(int j=0; j<sutun; j++)
{
System.out.print(i + " " + j + " elemanini giriniz : ");
dizi[i][j] = scanner.nextInt();
}
}
System.out.println("\n\nDizi\n\n");
for(int i=0; i<satir; i++)
{
for(int j=0; j<sutun; j++)
{
System.out.print(dizi[i][j] + " ");
}
System.out.println("\n");
}
double[][] newdizi = new double[satir][sutun];
for(int i=0; i<satir; i++)
{
int satirtoplam = 0;
double ort = 0;
for(int j=0; j<sutun; j++)
{
satirtoplam += dizi[i][j];
}
ort = (double)satirtoplam/sutun;
// System.out.println("Ortalama : " + ort);
for(int j=0; j<sutun; j++)
{
newdizi[i][j] = dizi[i][j] - ort;
if(newdizi[i][j] < 0)
{
newdizi[i][j] *= -1;
}
}
}
System.out.println("\n\nSatir Ortalamalarina Olan Uzakliklar Dizisi\n\n");
for(int i=0; i<satir; i++)
{
for(int j=0; j<sutun; j++)
{
System.out.print(df.format(newdizi[i][j]) + " ");
}
System.out.println("\n");
}
for(int i=0; i<sutun; i++)
{
int sutuntoplam=0;
double ort=0;
for(int j=0; j<satir; j++)
{
sutuntoplam += dizi[j][i];
}
ort = (double)sutuntoplam/satir;
// System.out.println("Ortalama : " + ort);
for(int j=0; j<satir; j++)
{
newdizi[j][i] = dizi[j][i] - ort;
if(newdizi[j][i] < 0)
{
newdizi[j][i] *= -1;
}
}
}
System.out.println("\n\nSutun Ortalamalarina Olan Uzakliklar Dizisi\n\n");
for(int i=0; i<satir; i++)
{
for(int j=0; j<sutun; j++)
{
System.out.print(df.format(newdizi[i][j]) + " ");
}
System.out.println("\n");
}
}
}