-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermuteLigne.java
More file actions
63 lines (56 loc) · 1.38 KB
/
PermuteLigne.java
File metadata and controls
63 lines (56 loc) · 1.38 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
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
/*un programme qui remplace dans un tableau à deux dimensions le contenu de la première ligne
par celui de la dernière et vice-versa, le contenu de la deuxième ligne par celui de l’avant dernière et vice-versa, etc */
import java.util.*;
public class PermuteLigne{
public static void main(String args[]){
int i, j, iTmp, nbL, nbC;
int tab[][], tmp[];
Scanner clavier = new Scanner(System.in);
System.out.println("Saisie le nombre ligne de tableau : ");
nbL = clavier.nextInt();
System.out.println("Saisie le nombre de colonne de tableau : ");
nbC = clavier.nextInt();
tab = new int[nbL][nbC];
tmp = new int[nbC];
System.out.println("Saise les elements : ");
//i = 0;
// while(i<nbL){
// j = 0;
// while(j<nbC){
// System.out.println("[ "+i+" ] [ "+j+" ]");
// tab[i][j] = clavier.nextInt();
// j++;
// }
// i++;
// }
for( i=0; i<nbL; i++){
for( j=0; j<nbC; j++){
System.out.println("[ "+i+" ] [ "+j+" ]");
tab[i][j] = clavier.nextInt();
}
}
System.out.println(Arrays.deepToString(tab));
i=0;
while(i<(nbL/2)){
j=0;
while(j< nbC){
tmp[j] =tab[i][j];
j++;
}
iTmp = ((nbL-1)-i);
j=0;
while(j<nbC){
tab[i][j] = tab[iTmp][j];
j++;
}
iTmp = ((nbL - 1) - i);
j = 0;
while(j<nbC){
tab[iTmp][j] = tmp[j];
j++;
}
i++;
System.out.println(Arrays.deepToString(tab));
}
}
}