From 6d79fc967ec8964e73a64715401a1f8594f00cac Mon Sep 17 00:00:00 2001 From: PIYUSH KHURANA <52041719+PIYUSH-01@users.noreply.github.com> Date: Mon, 21 Oct 2019 22:49:27 +0530 Subject: [PATCH] Update problem_6.cpp --- problem_6/problem_6.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/problem_6/problem_6.cpp b/problem_6/problem_6.cpp index 64edb8f..bfcb535 100644 --- a/problem_6/problem_6.cpp +++ b/problem_6/problem_6.cpp @@ -1 +1,15 @@ -//Wirte your code logic here! \ No newline at end of file +int find_jump(int x1, int v1, int x2, int v2) +{ + if(abs((x1+v1) - (x2+v2)) < abs(x2-x1)) + { + for(int i=0; ;i++) + { + x1 = x1 + v1; + x2 = x2 + v2; + if(x1 == x2) + return 1; + } + } + else + return 0; +}