From 5fb1f65f5dce98a630bdbda48b2ce69e02fe2290 Mon Sep 17 00:00:00 2001 From: Sickkkkk <2026865990@qq.com> Date: Fri, 22 Dec 2023 08:02:02 +0000 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E5=85=AD=E7=AB=A0=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sickkkkk <2026865990@qq.com> --- ...0\347\232\204\344\270\252\346\225\260.cpp" | 19 ++++++++++++++ ...3\347\264\240\347\232\204\345\222\214.cpp" | 11 ++++++++ .../chpter6/\347\247\273\345\212\2500.cpp" | 13 ++++++++++ ...5\345\241\221\347\237\251\351\230\265.cpp" | 26 +++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 "2209040054/chpter6/\346\234\200\345\244\247\350\277\236\347\273\255\344\270\272\344\270\200\347\232\204\344\270\252\346\225\260.cpp" create mode 100644 "2209040054/chpter6/\347\237\251\351\230\265\345\257\271\350\247\222\347\272\277\345\205\203\347\264\240\347\232\204\345\222\214.cpp" create mode 100644 "2209040054/chpter6/\347\247\273\345\212\2500.cpp" create mode 100644 "2209040054/chpter6/\351\207\215\345\241\221\347\237\251\351\230\265.cpp" diff --git "a/2209040054/chpter6/\346\234\200\345\244\247\350\277\236\347\273\255\344\270\272\344\270\200\347\232\204\344\270\252\346\225\260.cpp" "b/2209040054/chpter6/\346\234\200\345\244\247\350\277\236\347\273\255\344\270\272\344\270\200\347\232\204\344\270\252\346\225\260.cpp" new file mode 100644 index 00000000..514cbb3a --- /dev/null +++ "b/2209040054/chpter6/\346\234\200\345\244\247\350\277\236\347\273\255\344\270\272\344\270\200\347\232\204\344\270\252\346\225\260.cpp" @@ -0,0 +1,19 @@ +int findMaxConsecutiveOnes(int* nums, int numsSize) +{ + int max_count = 0; + int i = 0; + while(i < numsSize) { + if(nums[i] == 1) { + int count = 1; + while(i+1 < numsSize && nums[i+1] != 0) { + count++; + i++; + } + if(count > max_count) { + max_count = count; + } + } + i++; + } + return max_count; +} \ No newline at end of file diff --git "a/2209040054/chpter6/\347\237\251\351\230\265\345\257\271\350\247\222\347\272\277\345\205\203\347\264\240\347\232\204\345\222\214.cpp" "b/2209040054/chpter6/\347\237\251\351\230\265\345\257\271\350\247\222\347\272\277\345\205\203\347\264\240\347\232\204\345\222\214.cpp" new file mode 100644 index 00000000..9c25c7c0 --- /dev/null +++ "b/2209040054/chpter6/\347\237\251\351\230\265\345\257\271\350\247\222\347\272\277\345\205\203\347\264\240\347\232\204\345\222\214.cpp" @@ -0,0 +1,11 @@ +int diagonalSum(int** mat, int matSize, int* matColSize){ + int sum=0; + for (int i = 0,j=matSize - 1 ; i < matSize&&j>=0; i++,j--) + { + sum+=mat[i][i]+mat[j][i]; + } + if(matSize%2!=0) + sum-=mat[matSize/2][matSize /2]; + return sum; + +} \ No newline at end of file diff --git "a/2209040054/chpter6/\347\247\273\345\212\2500.cpp" "b/2209040054/chpter6/\347\247\273\345\212\2500.cpp" new file mode 100644 index 00000000..42db579e --- /dev/null +++ "b/2209040054/chpter6/\347\247\273\345\212\2500.cpp" @@ -0,0 +1,13 @@ +void moveZeroes(int* nums, int numsSize){ + int zero_count=0; + int i=0; + for(i=0;i