From 8c2bc8b50fbb68c9ddbd2f7c05a855b6eb7237de Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Wed, 20 Sep 2023 14:40:44 +0000 Subject: [PATCH 01/14] =?UTF-8?q?=E4=B8=A4=E6=95=B0=E4=B9=8B=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...70\244\346\225\260\344\271\213\345\222\214.cpp" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" diff --git "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" new file mode 100644 index 00000000..57ded778 --- /dev/null +++ "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" @@ -0,0 +1,14 @@ +class Solution { +public: + vector twoSum(vector& nums, int target) { + int n = nums.size(); + for (int i = 0; i < n - 1; ++i) { + for (int j = i + 1; j < n; ++j) { + if (nums[i] == target - nums[j]) { + return {i, j}; + } + } + } + return {}; + } +}; \ No newline at end of file -- Gitee From 1b2bc8715c439969a978a7b7b65c71896959dba7 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:28:45 +0000 Subject: [PATCH 02/14] ch1 --- 2224020102/chap1/ch1.1.1.cpp | 22 ++++++++++ 2224020102/chap1/ch1.2.1.cpp | 41 +++++++++++++++++++ 2224020102/chap1/chi.1.1.2.cpp | 20 +++++++++ ...4\346\225\260\344\271\213\345\222\214.cpp" | 2 +- 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 2224020102/chap1/ch1.1.1.cpp create mode 100644 2224020102/chap1/ch1.2.1.cpp create mode 100644 2224020102/chap1/chi.1.1.2.cpp diff --git a/2224020102/chap1/ch1.1.1.cpp b/2224020102/chap1/ch1.1.1.cpp new file mode 100644 index 00000000..cf252a4b --- /dev/null +++ b/2224020102/chap1/ch1.1.1.cpp @@ -0,0 +1,22 @@ +#include +main() +{ + int s=0,n,i; + scanf("%d",&n); + for(i=1;i<=n;i++) + { + s+=i; + } + printf("sum = %d",s); +} +void AddTime1(long n) +{ +clock_t t; +long sum; +t = clock(); +sum = add1(n); +t = clock() - t; +printf("方法1:\n"); +printf(" 结果:1~%d之和:%ld\n",n,sum); +printf("用时:%lf秒\n",((float)t)/CLOCKS_PER_SEC); +} diff --git a/2224020102/chap1/ch1.2.1.cpp b/2224020102/chap1/ch1.2.1.cpp new file mode 100644 index 00000000..8e341f7c --- /dev/null +++ b/2224020102/chap1/ch1.2.1.cpp @@ -0,0 +1,41 @@ +#include +#include + +int main() +{ + long long int t,j,u=0; + int isprime(int n); + printf("请输入一个数:"); + scanf("%d",&t); + for(j=1;j<=t;j++) + { + if (isprime(j)==1) u++; + } + printf("从1到%d总共有%d个素数。",t,u); + return 0; +} + +int isprime(int n) +{ + int i; + if(n==2) return 1; + else if(n==1||n%2==0) return 0; + for (i=3;i<=sqrt(n)+1;i+=2) + { + if(n%i==0) return 0; + } + return 1; +} +void PrimeTime(long n) +{ +clock_t t; +long sum=0, i; +t = clock(); +for (i = 2; i <= n;i++) + if (prime(i)) + sum++; +t = clock()-t; +printf("方法1:\n"); +printf(" 结果:2~%d素数个数:%ld\n",n,sum); +printf("用时:%lf秒\n",((float)t)/CLOCKS_PER_SEC); +} diff --git a/2224020102/chap1/chi.1.1.2.cpp b/2224020102/chap1/chi.1.1.2.cpp new file mode 100644 index 00000000..e5309354 --- /dev/null +++ b/2224020102/chap1/chi.1.1.2.cpp @@ -0,0 +1,20 @@ +#include +int main() +{ + int i,sum=0,n; + scanf("%d",&n); + sum=(1+n)*n/2; + printf("%d\n",sum); + return 0; + } +void AddTime1(long n) +{ +clock_t t; +long sum; +t = clock(); +sum = add1(n); +t = clock() - t; +printf("方法2:\n"); +printf(" 结果:1~%d之和:%ld\n",n,sum); +printf("用时:%lf秒\n",((float)t)/CLOCKS_PER_SEC); +} diff --git "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" index 57ded778..722cab84 100644 --- "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" +++ "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" @@ -11,4 +11,4 @@ public: } return {}; } -}; \ No newline at end of file +}; \ No newline at end of file -- Gitee From 5f5ceceb070dfb6661656cd0b335800bdff37127 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:28:56 +0000 Subject: [PATCH 03/14] ch1 -- Gitee From 474bfd1225b1f2ff02b74a1e1c0c9323f3d832c4 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:28:58 +0000 Subject: [PATCH 04/14] ch1 -- Gitee From 272c2cf2e20d84aa787050806dc8e92d70195ca5 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:29:01 +0000 Subject: [PATCH 05/14] ch1 -- Gitee From 279eeb8c50f0a6dfae85131a9bdac3e36a16144d Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:29:03 +0000 Subject: [PATCH 06/14] ch1 -- Gitee From ddac3b4c89d6caac7ed3764d2b61f70a0e6ff158 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:29:08 +0000 Subject: [PATCH 07/14] ch1 -- Gitee From 772740189e76c3a8616e260bcfc87ecc949c35e0 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:29:11 +0000 Subject: [PATCH 08/14] ch1 -- Gitee From dea1881158dc3dac07219e1225dfd6ddca5074a6 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:29:13 +0000 Subject: [PATCH 09/14] ch1 -- Gitee From 511e1faafccb93ace3ff81b22c5bcec9cae95633 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Thu, 21 Sep 2023 13:29:22 +0000 Subject: [PATCH 10/14] ch1 -- Gitee From c7bde4a93154e074a813dac7e636846a3e19142b Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Fri, 13 Oct 2023 06:42:31 +0000 Subject: [PATCH 11/14] 2224020102 --- ...70\244\346\225\260\344\271\213\345\222\214.cpp" | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" index 722cab84..6ad49e4f 100644 --- "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" +++ "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" @@ -1,14 +1,18 @@ class Solution { public: - vector twoSum(vector& nums, int target) { + vector twoSum(vector& nums, int target) + { int n = nums.size(); - for (int i = 0; i < n - 1; ++i) { - for (int j = i + 1; j < n; ++j) { - if (nums[i] == target - nums[j]) { + for (int i = 0; i < n - 1; ++i) + { + for (int j = i + 1; j < n; ++j) + { + if (nums[i] == target - nums[j]) + { return {i, j}; } } } return {}; } -}; \ No newline at end of file +} \ No newline at end of file -- Gitee From 68ebe7ea7e4d242932aa73b556f77348c9b6d39f Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Fri, 13 Oct 2023 06:42:37 +0000 Subject: [PATCH 12/14] 2224020102 -- Gitee From 566bcbe8e2f9aaa439892b03983d8a91c2c8fea8 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Fri, 13 Oct 2023 06:47:33 +0000 Subject: [PATCH 13/14] 222402012 --- .../chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" index 6ad49e4f..826c7a63 100644 --- "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" +++ "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" @@ -15,4 +15,4 @@ public: } return {}; } -} \ No newline at end of file +}; \ No newline at end of file -- Gitee From 047de20e763c2cee85c94311d31ff38c606c5b77 Mon Sep 17 00:00:00 2001 From: V <1965126556@qq.com> Date: Fri, 13 Oct 2023 06:58:03 +0000 Subject: [PATCH 14/14] 2224020102 --- 2224020102/chap1/ch1.1.1.cpp | 2 +- 2224020102/chap1/ch1.2.1.cpp | 2 +- 2224020102/chap1/chi.1.1.2.cpp | 2 +- .../chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/2224020102/chap1/ch1.1.1.cpp b/2224020102/chap1/ch1.1.1.cpp index cf252a4b..59b4537a 100644 --- a/2224020102/chap1/ch1.1.1.cpp +++ b/2224020102/chap1/ch1.1.1.cpp @@ -1,5 +1,5 @@ #include -main() +int main() { int s=0,n,i; scanf("%d",&n); diff --git a/2224020102/chap1/ch1.2.1.cpp b/2224020102/chap1/ch1.2.1.cpp index 8e341f7c..204b5cb1 100644 --- a/2224020102/chap1/ch1.2.1.cpp +++ b/2224020102/chap1/ch1.2.1.cpp @@ -11,7 +11,7 @@ int main() { if (isprime(j)==1) u++; } - printf("从1到%d总共有%d个素数。",t,u); + printf("从1到%d总共有%d个素数",t,u); return 0; } diff --git a/2224020102/chap1/chi.1.1.2.cpp b/2224020102/chap1/chi.1.1.2.cpp index e5309354..ed5511b1 100644 --- a/2224020102/chap1/chi.1.1.2.cpp +++ b/2224020102/chap1/chi.1.1.2.cpp @@ -14,7 +14,7 @@ long sum; t = clock(); sum = add1(n); t = clock() - t; -printf("方法2:\n"); +printf("方法:\n"); printf(" 结果:1~%d之和:%ld\n",n,sum); printf("用时:%lf秒\n",((float)t)/CLOCKS_PER_SEC); } diff --git "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" index 826c7a63..6ad49e4f 100644 --- "a/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" +++ "b/2224020102/chap1/\344\270\244\346\225\260\344\271\213\345\222\214.cpp" @@ -15,4 +15,4 @@ public: } return {}; } -}; \ No newline at end of file +} \ No newline at end of file -- Gitee