Browse Source

Version 1.0

master
Patrick Foubet 1 year ago
parent
commit
0ad92da557
54 changed files with 918 additions and 0 deletions
  1. +17
    -0
      annexe/exA_1.rs
  2. +17
    -0
      annexe/exA_2.rs
  3. +17
    -0
      etape1/ex1_1.rs
  4. +17
    -0
      etape1/ex1_2.rs
  5. +17
    -0
      etape2/ex2_1.rs
  6. +17
    -0
      etape2/ex2_2.rs
  7. +17
    -0
      etape2/ex2_3.rs
  8. +17
    -0
      etape2/ex2_4.rs
  9. +17
    -0
      etape2/ex2_5.rs
  10. +17
    -0
      etape2/ex2_6.rs
  11. +17
    -0
      etape2/ex2_7.rs
  12. +17
    -0
      etape2/ex2_8.rs
  13. +17
    -0
      etape3/ex3_1.rs
  14. +17
    -0
      etape3/ex3_2.rs
  15. +17
    -0
      etape3/ex3_3.rs
  16. +17
    -0
      etape3/ex3_4.rs
  17. +17
    -0
      etape3/ex3_5.rs
  18. +17
    -0
      etape3/ex3_6.rs
  19. +17
    -0
      etape3/ex3_7.rs
  20. +17
    -0
      etape3/ex3_8.rs
  21. +17
    -0
      etape4/ex4_1.rs
  22. +17
    -0
      etape4/ex4_2.rs
  23. +17
    -0
      etape4/ex4_3.rs
  24. +17
    -0
      etape4/ex4_4.rs
  25. +17
    -0
      etape4/ex4_5.rs
  26. +17
    -0
      etape4/ex4_6.rs
  27. +17
    -0
      etape4/ex4_7.rs
  28. +17
    -0
      etape4/ex4_8.rs
  29. +17
    -0
      etape5/ex5_1.rs
  30. +17
    -0
      etape5/ex5_2.rs
  31. +17
    -0
      etape5/ex5_3.rs
  32. +17
    -0
      etape5/ex5_4.rs
  33. +17
    -0
      etape5/ex5_5.rs
  34. +17
    -0
      etape5/ex5_6.rs
  35. +17
    -0
      etape6/ex6_1.rs
  36. +17
    -0
      etape6/ex6_2.rs
  37. +17
    -0
      etape6/ex6_3.rs
  38. +17
    -0
      etape6/ex6_4.rs
  39. +17
    -0
      etape6/ex6_5.rs
  40. +17
    -0
      etape6/ex6_6.rs
  41. +17
    -0
      etape6/ex6_7.rs
  42. +17
    -0
      etape7/ex7_1.rs
  43. +17
    -0
      etape7/ex7_2.rs
  44. +17
    -0
      etape7/ex7_3.rs
  45. +17
    -0
      etape7/ex7_4.rs
  46. +17
    -0
      etape7/ex7_5.rs
  47. +17
    -0
      etape7/ex7_6.rs
  48. +17
    -0
      etape7/ex7_7.rs
  49. +17
    -0
      etape8/ex8_1.rs
  50. +17
    -0
      etape8/ex8_2.rs
  51. +17
    -0
      etape8/ex8_3.rs
  52. +17
    -0
      etape8/ex8_4.rs
  53. +17
    -0
      etape8/ex8_5.rs
  54. +17
    -0
      etape8/ex8_6.rs

+ 17
- 0
annexe/exA_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let check : bool = true ; // suppose que c'est vrai
assert ! (check == true) ; // vérifier l'erreur


+ 17
- 0
annexe/exA_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let check : bool = false ; // suppose que c'est faux
assert ! (check == true) ; // vérifier l'erreur


+ 17
- 0
etape1/ex1_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
println ! ("Bonjour, monde !") ;
}

+ 17
- 0
etape1/ex1_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() { // définit une fonction nommée main
println ! ("Bonjour, monde ! ") ;
/* println!( ) est une commande utilisée pour afficher du contenu ou du texte.


+ 17
- 0
etape2/ex2_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let var = "OK" ;
println! ("La valeur de var est : { }", var);


+ 17
- 0
etape2/ex2_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let var : i32 = 100 ;
let str : String = "Bonne".to_string() ;


+ 17
- 0
etape2/ex2_3.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let x = 100 ;
let y = 200 ;


+ 17
- 0
etape2/ex2_4.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

const NUM : i32 = 100 ;
fn main() {
println ! ("La valeur de NUM est {}", NUM) ;


+ 17
- 0
etape2/ex2_5.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let var1 : f32 = 100.88 ;
let var2 : i32 = var1 as i32 ; // var1 devient i32


+ 17
- 0
etape2/ex2_6.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
funt(100, 200) ; // appelle la fonction
}


+ 17
- 0
etape2/ex2_7.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let num = funt(100) ; // appelle la fonction
println ! ("La valeur de num est : { }", num) ;


+ 17
- 0
etape2/ex2_8.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn foo() -> bool { // spécifier un type de retour
return true // renvoie une valeur à l'appelant
}


+ 17
- 0
etape3/ex3_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let (x, y) = (100, 200) ; // liaison de variable
println ! ("La valeur de x est {}", x) ;


+ 17
- 0
etape3/ex3_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let mut a = 100 ; // liaison de variable
let mut b = 200 ;


+ 17
- 0
etape3/ex3_3.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let x = "hello".to_string() ;
let y = String::from("hello") ;


+ 17
- 0
etape3/ex3_4.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
println ! ("10 + 2 = {}", 10 + 2) ;
println ! ("10 - 2 = {}", 10 - 2) ;


+ 17
- 0
etape3/ex3_5.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
println ! ("true AND false is {}", true && false) ;
println ! ("true OR false is {}", true || false) ;


+ 17
- 0
etape3/ex3_6.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let x : i32 = 100 ;
let y : i32 = 200 ;


+ 17
- 0
etape3/ex3_7.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let mut a : [i32 ; 4] = [8 ; 4] ; // créer un tableau
a[1] = 10 ;


+ 17
- 0
etape3/ex3_8.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let a :[f32 ; 4] = [0.1, 0.2, 0.3, 0.4] ; // créer un tableau
println ! ("{} {} {} {}",a[0],a[1],a[2],a[3])


+ 17
- 0
etape4/ex4_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let num=10 ;
if num==10 {


+ 17
- 0
etape4/ex4_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let x=100 ;
let y=200 ;


+ 17
- 0
etape4/ex4_3.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let num = if true { // instruction let-if
100


+ 17
- 0
etape4/ex4_4.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let mut num=5 ;
loop { // instruction de boucle


+ 17
- 0
etape4/ex4_5.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
for num in 5..9 { // "5 .. 9" contient les nombres de 5 à 8
println ! ("Cela va durer {} heures", num) ;


+ 17
- 0
etape4/ex4_6.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let mut num=0 ;
while num<=8 { // instruction while


+ 17
- 0
etape4/ex4_7.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let t = ("Nous nous levons à", 8,"Heures",true); // crée un tuple
print!("{} {} {} {}\n",t.0,t.1,t.2,t.3 ) ; // accède aux éléments


+ 17
- 0
etape4/ex4_8.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let num:i32 = 3 ; // expression donnée
match num {


+ 17
- 0
etape5/ex5_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

struct Member { // créer une structure
id : i32, // member : type
name : String,


+ 17
- 0
etape5/ex5_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

struct Square { // crée une structure
len : i32,
wid : i32,


+ 17
- 0
etape5/ex5_3.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

enum Langage { // définit un enum
JS, // membre
Rust,


+ 17
- 0
etape5/ex5_4.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){

let x = String::from("E2L") ; // x est propriétaire de "E2L".


+ 17
- 0
etape5/ex5_5.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let s =String::from("Il fait beau") ; // s est propriétaire
// de "Il fait beau".


+ 17
- 0
etape5/ex5_6.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let s=String :: from("Vive le Rust !");
let n=cal( &s ); // reference


+ 17
- 0
etape6/ex6_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

mod mon_module { // définit un module
pub fn test(){ // pub signifie attribut public
println ! ("Bonjour mes amis ! ") ;


+ 17
- 0
etape6/ex6_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

mod m1{
pub fn a(){
println ! ("module m1") ;


+ 17
- 0
etape6/ex6_3.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

pub fn ex_fun() {
println ! ("{}", "Texte externe") ;
}

+ 17
- 0
etape6/ex6_4.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

mod ex6_3 ; // charge un fichier externe
use ex6_3::ex_fun ; // charge une fonction externe
fn main () {


+ 17
- 0
etape6/ex6_5.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

mod mon_module {
pub fn a() { // la fonction est publique
println ! ("fonction a") ;


+ 17
- 0
etape6/ex6_6.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

mod mon_module {
pub fn a() {
println ! ("fonction a") ;


+ 17
- 0
etape6/ex6_7.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

mod sup_module{ // module parent
fn a() -> i32 {
100


+ 17
- 0
etape7/ex7_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let v = vec ![100, 200, 300, 400] ; // crée un vecteur
println ! ("Le premier élément est : {}",v[0]) ; // accède au premier élément


+ 17
- 0
etape7/ex7_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let v =vec ! [8 ; 3] ; // répété trois fois
println ! ("Le premier élément est : {}",v[0]) ;


+ 17
- 0
etape7/ex7_3.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let mut v=Vec::new() ; // crée un vecteur
v . push('R') ; // définit R comme le premier élément du vecteur


+ 17
- 0
etape7/ex7_4.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let num = 3 ;
match num {


+ 17
- 0
etape7/ex7_5.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let x = 3 ;
match x {


+ 17
- 0
etape7/ex7_6.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let x = 5 ;
match x {


+ 17
- 0
etape7/ex7_7.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let x : Option<bool> = Some(true) ; // paramètres génériques
let y : Option<i32> = Some(10) ;


+ 17
- 0
etape8/ex8_1.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

struct Circle{ // création d'une structure de type
radius : f32, // membre de la structure
}


+ 17
- 0
etape8/ex8_2.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

struct Cercle{ // créez une structure de type
rayon : f32, // membre de la structure
}


+ 17
- 0
etape8/ex8_3.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

pub trait Show { // définit un trait
fn show(&self) ; // définition d'une méthode de trait
}


+ 17
- 0
etape8/ex8_4.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

struct Jeu {
numero : i32,
}


+ 17
- 0
etape8/ex8_5.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main(){
let ma_fermeture = | num : i32 | { num+200 }; //crée une fermeture
let num = 100 ;


+ 17
- 0
etape8/ex8_6.rs View File

@@ -1,3 +1,20 @@
/* Copyright (C) 2011-2023 Patrick H. E. Foubet - E2L Ivry
Ecole du Logiciel Libre : https://e2li.org/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or any
later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************/

fn main() {
let mut capacity = "Capacité du disque dur : 5000".to_string() ;
{


Loading…
Cancel
Save