-
Notifications
You must be signed in to change notification settings - Fork 78
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
完成了running letter #32
base: master
Are you sure you want to change the base?
Changes from 8 commits
bec1370
3f73640
2ac63b7
bf75807
e26d96d
5f014e1
2356fcb
4cdf1fc
bd24ae4
1ec64ee
9da8788
549129c
5f1fe82
3f3305a
7e340fa
d214aba
dc210c8
2b737f7
2530e96
c9d8dfc
da9cf3b
fbcfb3e
d3243b1
ad0faa3
244422f
67c075d
517d040
da4f9c9
9412054
9fae957
650d8d0
ad232b9
d3ec29a
07311d7
a8d0c59
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,36 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <windows.h> | ||
#define Length 20 | ||
|
||
int main () | ||
{ | ||
int a=0; | ||
int b=1; | ||
while(1) | ||
{ | ||
a+=b; | ||
system("cls"); | ||
int i=0; | ||
while(i<a) | ||
{ | ||
printf(" "); | ||
i++; | ||
} | ||
printf("H"); | ||
Sleep(100); | ||
if(a==Length) | ||
{ | ||
b=-1; | ||
} | ||
if(a==0) | ||
{ | ||
b=1; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <windows.h> | ||
#define LENGTH 20 | ||
|
||
int main () | ||
{ | ||
int a=0; | ||
int b=1; | ||
while(1) | ||
{ | ||
a+=b; | ||
system("cls"); | ||
int i=0; | ||
while(i<a) | ||
{ | ||
printf(" "); | ||
i++; | ||
} | ||
printf("H"); | ||
Sleep(100); | ||
if(a==Length) | ||
{ | ||
b=-1; | ||
} | ||
if(a==0) | ||
{ | ||
b=1; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
unsigned int a; | ||
printf("��������һ��������:"); | ||
scanf("%u",&a); | ||
int i,b=0; | ||
for(i=1;i<=a;i++) | ||
{ | ||
if(a%i==0) | ||
{ | ||
b++; | ||
} | ||
} | ||
if(b==2||b==1) | ||
{ | ||
printf("%u��������\n",a); | ||
} | ||
else | ||
{ | ||
printf("%u����������\n",a); | ||
} | ||
|
||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### ��̽����������⣺ | ||
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. 这段markdown在代码里面,能编译过? |
||
|
||
ȡ�ԡ�ϣ��ʫѡ����Greek Anthology���� | ||
|
||
����ͼ��ͯ�꾭������һ��������֮һ�� | ||
|
||
���꾭����ʮ����֮һ�� | ||
|
||
�����߷�֮һ��ʱ���ǵ������� | ||
|
||
����������˸����ӣ� | ||
|
||
���ӱȸ����������꣬ | ||
|
||
�꼶������һ�롣 | ||
|
||
�ʶ�����ʱ����ͼ��� | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int age; | ||
for(age=1;;age++) | ||
{ | ||
if(age*1.0/6+age*1.0/12+age*1.0/7+5+4==age*1.0/2) | ||
{ | ||
age-=4; | ||
printf("����ͼ������ʱ����ͼ%d�ꡣ",age); | ||
break; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include<stdio.h> | ||
int main() | ||
{ | ||
int hun,dec,uni,med,nar; | ||
for(med=100;med<=999;med++) | ||
{ | ||
hun=med/100; | ||
dec=(med-(hun*100))/10; | ||
uni=(med-(hun*100)-dec*10); | ||
nar=hun*hun*hun+dec*dec*dec+uni*uni*uni; | ||
if (nar==med) | ||
printf("%d ",nar); | ||
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"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include<stdio.h> | ||
#include <math.h> | ||
#include <Windows.h> | ||
void CreatePrime(int *primes, int n) | ||
{ | ||
int i, j, s; | ||
primes[0] = primes[1] = 0; | ||
for(i = 2; i < n; i++) | ||
primes[i] = 1; | ||
s = sqrt(n); | ||
for(i = 2; i<= s; i++) | ||
{ | ||
if(primes[i]) | ||
{ | ||
for(j = 2 * i; j < n; j+=i) | ||
primes[j] = 0; | ||
} | ||
} | ||
} | ||
int main() | ||
{ | ||
int i; | ||
double run_time; | ||
LARGE_INTEGER time_start; | ||
LARGE_INTEGER time_over; | ||
double dqFreq; | ||
LARGE_INTEGER f; | ||
QueryPerformanceFrequency(&f); | ||
dqFreq=(double)f.QuadPart; | ||
QueryPerformanceCounter(&time_start); | ||
int IsPrime[1000]; | ||
CreatePrime(IsPrime, 1000); | ||
for(i = 2; i < 1000; i++) | ||
if(IsPrime[i]) | ||
printf("%d\t",i); | ||
QueryPerformanceCounter(&time_over); | ||
run_time=1000000*(time_over.QuadPart-time_start.QuadPart)/dqFreq; | ||
printf("\nrun_time��%fus\n",run_time); | ||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
1. 打印2-1000以内的所有素数 | ||
1. 打印出总的计算时间 | ||
1. 尽可能优化算法的效率 | ||
1. 尽可能优化算法的效率 | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <stdio.h> | ||
|
||
int isPrime(int n); | ||
|
||
int main() | ||
{ | ||
int i = 0; | ||
int j = 0; | ||
int k1 = 0; | ||
int k2 = 0; | ||
int even[50]; | ||
int ret1 = 0; | ||
int ret2 = 0; | ||
int count = 0; | ||
for(i=4;i<=100;i+=2) | ||
{ | ||
count = 0; | ||
j = i; | ||
k1 = j-1 ; | ||
while(k1>=(j/2)) | ||
{ | ||
ret1 = isPrime(k1); | ||
if(ret1) | ||
{ | ||
k2 = j - k1; | ||
ret2 = isPrime(k2); | ||
if(ret2) | ||
{ | ||
printf("%d = %d + %d,", j, k2, k1); | ||
count ++; | ||
} | ||
} | ||
k1--; | ||
} | ||
printf("%d���Բ��Ϊ%d�飡\n", i, count); | ||
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. 文件的encoding需要用utf-8,这样就不会乱码了 |
||
|
||
} | ||
return 0; | ||
} | ||
int isPrime(int n) | ||
{ | ||
int i = 0; | ||
if(n<=1) | ||
{ | ||
return 0; | ||
} | ||
if(2==n) | ||
{ | ||
return 1; | ||
} | ||
for(i=2;i<n;i++) | ||
{ | ||
if(0==n%i) | ||
{ | ||
return 0; | ||
} | ||
} | ||
return 1; | ||
} |
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.
一般常量用全大写