forked from mouha090/java-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexo2.java
More file actions
37 lines (37 loc) · 1.07 KB
/
Copy pathexo2.java
File metadata and controls
37 lines (37 loc) · 1.07 KB
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
public class exo2{
static void histog (int v[], int nb){
int max=0;
// if(nb >= 0)
// max=v[0];
for(int i=0; i<nb; i++){
if(max< v[i])
max=v[i];
}
for(int i=0; i<=max; i++){
for(int j=0; j<nb; j++){
if((max-i)<=v[j])
System.out.print("* ");
else
System.out.print(" ");
}
System.out.println();
}
}
static void histog (int v[], int nb, int H){
for(int i=0; i<=H; i++){
for(int j=0; j<nb; j++){
if((H-i)<=v[j])
System.out.print("* ");
else
System.out.print(" ");
}
System.out.println();
}
}
public static void main(String []args){
//int v[]= new int[30];
int v[]={2,3,7,6,9,11,12,15,18,17,14,13,12,7,8,7,5,3,2,1,1,0,2,8,11,13,12,11,6,3};
histog(v, v.length);
//histog(v, v.length, 25);
}
}