-
Notifications
You must be signed in to change notification settings - Fork 35
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
level_1_p01.c to level_1_p06.c #40
base: master
Are you sure you want to change the base?
Changes from 8 commits
2681033
4537a75
d3ec73b
d255127
8349492
f4a5ef9
d136750
086e6a6
8c45bee
d1fe42d
bcb1c1f
e08c447
9415fcf
283b692
cb5ada2
b25197a
37bedc5
75e012f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include<stdio.h> | ||
#include<windows.h> | ||
main() | ||
{ | ||
for(int i=1;i<=50;i++){ | ||
for(int j=1;j<=i;j++){ | ||
printf(" "); | ||
} | ||
printf("R"); | ||
Sleep(10); | ||
system("cls"); | ||
} | ||
for(int i=50;i>=1;i--){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 闻到了重复的味道,这两个循环较相似,设法消除之 |
||
for(int j=i;j>=1;j--){ | ||
printf(" "); | ||
} | ||
printf("R"); | ||
Sleep(10); | ||
system("cls"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include<stdio.h> | ||
main() | ||
{ | ||
int a; | ||
scanf("%d",&a); | ||
if(a==1){ | ||
printf("非素数");} | ||
for(int i=2;i<=a-1;i++){ | ||
if(a%i==0){ | ||
printf("非素数"); | ||
break;} | ||
else | ||
printf("素数"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include<stdio.h> | ||
main() | ||
{ | ||
int ageDio;int ageSon; | ||
int i,j; | ||
for(i=1;i<=100;i++) | ||
for(j=1;j<=100;j++){ | ||
ageDio=12*i*7*j; | ||
ageSon=ageDio/2; | ||
if(ageSon==((ageDio-4)-(ageDio*11/28+5))){ | ||
printf("%d",ageDio); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include<stdio.h> | ||
main() | ||
{ | ||
int a,b,c,result;int i; | ||
for(a=1;a<=9;a++) | ||
for(b=0;b<=9;b++) | ||
for(c=0;c<=9;c++){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缩进有点不齐 |
||
if(100*a+10*b+c==a*a*a+b*b*b+c*c*c) | ||
printf("%d\n",100*a+10*b+c); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include<stdio.h> | ||
#include<math.h> | ||
#include<time.h> | ||
int prime(int); | ||
main() | ||
{ | ||
int i,j; | ||
for(i=2;i<=1000;i++){ | ||
if(prime(i)>0) | ||
printf("%d\n",i); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缩进; |
||
} | ||
printf("\n"); | ||
printf("%d",(int)clock()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这样算时间有点不准,因为程序启动等时间也没包含在了里面 |
||
} | ||
|
||
int prime(int m) | ||
{ | ||
int k;int i; | ||
k=sqrt(m); | ||
for (i=2;i<=k;i++) | ||
if (m%i==0) break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 加上大括号吧,我这种老手看起来都晕,真不知道循环包含哪些语句呢 |
||
if (i>k) return m; | ||
else return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include<stdio.h> | ||
#include<math.h> | ||
int checkprime(int m) | ||
{ | ||
int k;int i; | ||
k=sqrt(m); | ||
for (i=2;i<=k;i++) | ||
if (m%i==0) break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上; |
||
if (i>k) return 1; | ||
else return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
int a;int prime[100];int b;int c=0; | ||
|
||
for(int i=2;i<=100;i++){ | ||
b=checkprime(i); | ||
if(b==1){ | ||
prime[c]=i; | ||
c++; | ||
} | ||
|
||
} | ||
for(int i=2;i<=50;i++){ | ||
for(int j=0;j<=24;j++){ | ||
a=2*i-prime[j]; | ||
if(checkprime(a)==1){ | ||
printf("%d=%d+%d\n",2*i,a,prime[j]);break; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加个空行