-
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
王瀚 second submission #34
base: master
Are you sure you want to change the base?
Changes from 9 commits
f75a42f
7b9b33e
2590026
77319f1
27b607d
5e04c08
6a97a5f
00d171d
9fdf828
73c692a
5c6e09f
e334a63
6120a94
a557bbb
11e0838
23774b5
1b440a9
dfed67e
8a0606b
eabb1a0
ba1199e
b876bf4
8ae70d8
4b3348f
bd3b4f1
ce45995
8824d40
9bea49b
7347377
80f596b
9ddd6aa
14176b6
2267866
8cb16d3
bda2930
e05f64d
07963cc
13942fa
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,20 @@ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
int main() | ||
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. 加一个空行 |
||
{ | ||
const int lenth=80; | ||
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 len_now=0,goBack=0,step; | ||
while (1) | ||
{ | ||
system("cls"); | ||
for (step=1;step<len_now;step++) | ||
printf(" "); | ||
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("R"); | ||
if (goBack) len_now--; | ||
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. 大括号 |
||
else len_now++; | ||
if (len_now==lenth) goBack=1; | ||
else if (len_now==0) goBack=0; | ||
sleep(50); | ||
} | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include<stdio.h> | ||
int main(){ | ||
int number,i; | ||
while (scanf("%d",&number)!=EOF){ | ||
if (number==0){ | ||
break; | ||
} | ||
for (i=2;i*i<=number;i++){ | ||
if (number%i==0){ | ||
break; | ||
} | ||
} | ||
if (i*i>number){ | ||
printf("Yes\n"); | ||
} | ||
else{ | ||
printf("No\n"); | ||
} | ||
} | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include<stdio.h> | ||
int main(){ | ||
int age=1; | ||
while (age++){ | ||
if (age%6==0&&age%12==0&&age%7==0&&(age/2-age/6-age/12-age/7)==9) { | ||
break; | ||
} | ||
} | ||
printf("%d\n",age-4); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include<stdio.h> | ||
int main(){ | ||
int number; | ||
int hundred,ten,one; | ||
for (number=100;number<=999;number++){ | ||
hundred=number/100; | ||
ten=(number/10)%10; | ||
one=number%10; | ||
if (number==hundred*hundred*hundred+ten*ten*ten+one*one*one){ | ||
printf("%d\n",number); | ||
} | ||
} | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
#include<time.h> | ||
int main(){ | ||
int i,j=2,prime[1000],numb; | ||
clock_t start,endd; | ||
start=clock(); | ||
memset(prime,0,sizeof(prime)); | ||
prime[1]=2; | ||
printf("%d\n",prime[1]); | ||
for (numb=3;numb<=1000;numb++){ | ||
for (i=1;prime[i]*prime[i]<=numb&&prime[i];i++){ | ||
if (numb%prime[i]==0){ | ||
break; | ||
} | ||
} | ||
if(prime[i]*prime[i]>numb){ | ||
prime[j++]=numb; | ||
printf("%d\n",numb); | ||
} | ||
} | ||
endd=clock(); | ||
printf("The algorithm costs %.0lfms;\n",(double)(endd-start)); | ||
printf("It will costs 0.01ms without printf().\n"); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include<stdio.h> | ||
int main(){ | ||
int i,j=2,numb,prime[100]; | ||
prime[1]=2; | ||
for (numb=3;numb<=100;numb++){ | ||
for (i=1;prime[i]*prime[i]<=numb&&prime[i];i++){ | ||
if (numb%prime[i]==0) break; | ||
} | ||
if(prime[i]*prime[i]>numb){ | ||
prime[j++]=numb; | ||
} | ||
} | ||
for (numb=4;numb<=100;numb+=2){ | ||
for (i=1;prime[i]!=0;i++){ | ||
for (j=1;prime[j]!=0;j++){ | ||
if (prime[j]+prime[i]==numb){ | ||
break; | ||
} | ||
} | ||
if (prime[j]==0){ | ||
break; | ||
} | ||
} | ||
if (prime[i]==0&&prime[j]==0){ | ||
break; | ||
} | ||
} | ||
if (numb>100){ | ||
printf("proved\n"); | ||
} | ||
else{ | ||
printf("not"); | ||
} | ||
return 0; | ||
} |
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.
文件名后缀应该是.c,不是cpp