Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

原杨锴♂2018081303017 #29

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions level1/p01_runningLetter/runningLetter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#define LENGTH 117
int main()
{
int flag=0,a=0;

while(1)
{
for(int i=a;i>0;--i)
printf(" ");

printf("Van");
Sleep(70);
system("cls");

if(a==0)
flag=0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缩进不对

if(a==length)
flag=1;

if(flag)
--a;
else
++a;
}

return 0;
}
31 changes: 31 additions & 0 deletions level1/p02_isPrime/isPrinme.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include<stdio.h>
#include<math.h>
int main()
{
int n,flag=1;

scanf("%d",&n);
if(n<=1)
{
printf("%d不是素数\n",n);
flag=0;
}
if(n%6!=1&&n%6!=5&&n>6)//如果n大于6且不与6的倍数为邻 ,n不是素数
printf("%d不是素数\n",n);
else
{
for(int a=sqrt(n);a>=2;--a)
{
if(n%a==0)
{
printf("%d不是素数\n",n);
flag=0;
break;
}
}
if(flag)
printf("%d是素数\n",n);
}

return 0;
}
15 changes: 15 additions & 0 deletions level1/p03_Diophantus/Diophantus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<stdio.h>
int main()
{
for(int age=12;age<=200;++age)//不能再多了
{
if(age%12==0&&age%7==0)
{
int x=age/6+age/12+age/7+5+age/2+4;
if(x==age)
printf("%d",x-4);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缩进不对,加大括号

}
}

return 0;
}
20 changes: 20 additions & 0 deletions level1/p04_ narcissus/narcissus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<stdio.h>
#include<math.h>
#define max 3

int pick(int x);

int main()
{
int all=0;
for(int x=100;x<1000;++x)
{
for(int i=0;i<max;++i)
all+=(int)pow((int)(x/pow(10,i))%10,max);
if(x==all)
printf("%d ",x);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缩进

all=0;
}

return 0;
}
48 changes: 48 additions & 0 deletions level1/p05_allPrimes/allPrimes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include<stdio.h>
#include<math.h>
#include<time.h>

clock_t start, stop;
double duration;

int main()
{
start = clock();

int num[999];
for(int i=0;i<999;++i)//Ϊÿ����ƥ��һ��״̬�����Ĭ�Ͼ�Ϊ������1��
{
num[i]=1;
}
for(int shu=2;shu<=1000;++shu)//��ÿ���������ж�
{
if(1==num[shu-2])// �����δ���жϲ������� (0)
{
for(int q=sqrt(shu);q>1;--q)//�����жϴ����Ƿ�Ϊ����
{
if(0==shu%q)//����������������״̬��0��
{
num[shu-2]=0;
}
}
if(1==num[shu-2])//�����������
{
for(int i=2;shu*i<=1000;++i)//��Ǵ������ı���Ϊ��������0��
{
num[shu*i-2]=0;
}
}
}
}
for(int i=0;i<999;++i)//��ÿ�����������������1�������
{
if(1==num[i])
printf("%d\n",i+2);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缩进+大括号

}

stop = clock();
duration = ((double)(stop - start))/CLK_TCK;
printf("����ʱ��Ϊ%fs\n",duration);

return 0;
}
45 changes: 45 additions & 0 deletions level1/p06_Goldbach/Goldbach.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include<stdio.h>
#include<math.h>
#define MAX 100

int isprime(int n);

int main()
{
for(int i=2,num=4;num<MAX;++i,num=2*i)
{
for(int d=0;d<num/2;++d)
{
int flag_1=isprime(num/2-d);
int flag_2=isprime(num/2+d);
if(flag_1&&flag_2)
{
printf("ż��%d�ɱ���ʾΪ����%d��%d�ĺ�\n",num,num/2-d,num/2+d);
break;
}
}
}

return 0;
}

int isprime(int n)
{
int flag=1;

if(n%6!=1&&n%6!=5&&n>6)//���n����6�Ҳ���6�ı���Ϊ�� ,n��������
flag=0;
else
{
for(int a=sqrt(n);a>=2;--a)
{
if(n%a==0)
{
flag=0;
break;
}
}
}

return flag;
}