Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
Hepper123 committed Mar 9, 2021
1 parent 31de5e3 commit 3cc3560
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion level1/p03_Diophantus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

儿子比父亲先死四年,

年级是他的一半
年纪是他的一半

问儿子死时丢番图多大?
59 changes: 59 additions & 0 deletions level1/p06_Goldbach/Goldbach.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include<stdio.h>

int main()
{
int i = 2;
int IsPrime = 1;
int a[50] = { 0 };
int k = 0;
for (i = 2; i <= 100; i++)
{
IsPrime = 1;
for (int j = 2; j <= i / 2; j++)
{
if (i % j == 0)
{
IsPrime = 0;
break;
}
}
if (IsPrime == 1)
{
a[k] = i;
k++;
}
}
int sum = 0;
int h = 4;
for (h = 4; h <= 100; h = h + 2)
{
int s = 1;
for (int x = 0; x < k; x++)
{
for (int y = 0; y <= x; y++)
{
if (a[x] + a[y] == h)
{
s = 0;
break;
}
}
if (s == 0)
{
break;
}
}
if (s == 0)
{
sum++;
}
}
if (sum == 49)
{
printf("哥德巴赫猜想在100范围内是正确的");
}
else
{
printf("哥德巴赫猜想在100范围内不是正确的");
}
}

0 comments on commit 3cc3560

Please sign in to comment.