From 1a35f6ade3da7e846936b9aed5e1ebbc9c7429c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=91=9E=E6=B3=BD?= <2456229381@qq.com> Date: Sun, 20 Nov 2022 15:48:25 +0000 Subject: [PATCH] add TP4-2. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王瑞泽 <2456229381@qq.com> --- TP4-2 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 TP4-2 diff --git a/TP4-2 b/TP4-2 new file mode 100644 index 0000000..d50572a --- /dev/null +++ b/TP4-2 @@ -0,0 +1,77 @@ +#include +#include +#include + +using namespace std; + +//question 4,5 +int uniquePathsWithObstacles(int** obstacleGrid, int m, int n){ + int i=0; + int j=0; + int chemin[m][n]={0}; + if((m==1)||(n==1)){ + if((m==1)&&(n==1)){ + if(obstacleGrid[0][0]==1){ + return 0; + }else{ + return 1; + } + }else{ + if(m==1){ + for(i=0;i