aboutsummaryrefslogtreecommitdiff
path: root/rush00/ex01
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-05-21 13:49:01 +0200
committerCharles <sircharlesaze@gmail.com>2020-05-21 13:49:01 +0200
commit6a8ffb8823e1bdca56b8058e496479b65d0a6f6f (patch)
treeda6300a879112dce942fc6efdb221201caba4831 /rush00/ex01
parentaef0e5fc3f4fdaa20d9334ac635d907cff82f2ba (diff)
downloadpiscine-master.tar.gz
piscine-master.tar.bz2
piscine-master.zip
Rush00 in Rust???HEADmaster
Diffstat (limited to 'rush00/ex01')
-rw-r--r--rush00/ex01/main.rs17
-rw-r--r--rush00/ex01/rush01.rs52
2 files changed, 69 insertions, 0 deletions
diff --git a/rush00/ex01/main.rs b/rush00/ex01/main.rs
new file mode 100644
index 0000000..ced1d94
--- /dev/null
+++ b/rush00/ex01/main.rs
@@ -0,0 +1,17 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* main.rs :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/21 12:35:44 by charles #+# #+# */
+/* Updated: 2020/05/21 13:35:46 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+mod rush01;
+
+fn main() {
+ rush01::rush(5, 5);
+}
diff --git a/rush00/ex01/rush01.rs b/rush00/ex01/rush01.rs
new file mode 100644
index 0000000..70e1534
--- /dev/null
+++ b/rush00/ex01/rush01.rs
@@ -0,0 +1,52 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* rush01.rs :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/05/21 13:38:25 by charles #+# #+# */
+/* Updated: 2020/05/21 13:38:25 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+pub fn rush(x: i32, y: i32) {
+ if x == 0 || y == 0 {
+ return ;
+ }
+
+ if x >= 1 {
+ print!("/");
+ }
+ for _ in 1..x - 1 {
+ print!("*");
+ }
+ if x >= 2 {
+ print!("\\");
+ }
+ print!("\n");
+
+ for _ in 1..y - 1 {
+ print!("*");
+ for _ in 1..x - 1 {
+ print!(" ");
+ }
+ if x >= 2 {
+ print!("*");
+ }
+ print!("\n");
+ }
+
+ if y > 1 {
+ if x >= 1 {
+ print!("\\");
+ }
+ for _ in 1..x - 1 {
+ print!("*");
+ }
+ if x >= 2 {
+ print!("/");
+ }
+ print!("\n");
+ }
+}