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

完成了running letter #32

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bec1370
完成了running letter
Mar 2, 2019
3f73640
Level 1 Exercise 2
C-ice-y Mar 20, 2019
2ac63b7
Level 1Exercise 3
C-ice-y Mar 20, 2019
bf75807
Level 1 Exercise 4
C-ice-y Mar 20, 2019
e26d96d
Level1 Exercise 1 update
C-ice-y Mar 20, 2019
5f014e1
level1 Exercise5
C-ice-y Mar 25, 2019
2356fcb
Update README.md
C-ice-y Mar 25, 2019
4cdf1fc
Level1 Exercise6
C-ice-y Mar 25, 2019
bd24ae4
Update L1T4.cpp
C-ice-y Mar 27, 2019
1ec64ee
Update L1T5.cpp
C-ice-y Mar 27, 2019
9da8788
Update L1T3.cpp
C-ice-y Mar 27, 2019
549129c
Exercise L1T8
C-ice-y Apr 3, 2019
5f1fe82
Update README.md
C-ice-y Apr 3, 2019
3f3305a
Add files via upload
C-ice-y Jun 23, 2019
7e340fa
Add files via upload
C-ice-y Jun 23, 2019
d214aba
Add files via upload
C-ice-y Jun 23, 2019
dc210c8
Add files via upload
C-ice-y Jun 23, 2019
2b737f7
Create FiveChess
C-ice-y Jun 23, 2019
2530e96
Delete FiveChess
C-ice-y Jun 23, 2019
c9d8dfc
Add files via upload
C-ice-y Jun 23, 2019
da9cf3b
Delete 五子棋txt.txt
C-ice-y Jun 23, 2019
fbcfb3e
Delete thoughts of WUZIQI.txt
C-ice-y Jun 23, 2019
d3243b1
Add files via upload
C-ice-y Jun 23, 2019
ad0faa3
Add files via upload
C-ice-y Jun 23, 2019
244422f
Delete mazeutf.txt
C-ice-y Jun 26, 2019
67c075d
Add files via upload
C-ice-y Jun 26, 2019
517d040
Delete 推箱子utf.txt
C-ice-y Jun 26, 2019
da4f9c9
Add files via upload
C-ice-y Jun 26, 2019
9412054
Delete 链表.txt
C-ice-y Jun 26, 2019
9fae957
Add files via upload
C-ice-y Jun 26, 2019
650d8d0
Delete utf超市.txt
C-ice-y Jun 26, 2019
ad232b9
Add files via upload
C-ice-y Jun 26, 2019
d3ec29a
Add files via upload
C-ice-y Jun 26, 2019
07311d7
Update 五子棋txt.txt
C-ice-y Jun 26, 2019
a8d0c59
Update 五子棋txt.txt
C-ice-y Jun 26, 2019
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
36 changes: 36 additions & 0 deletions level1/p01_runningLetter/L1T1.cpp
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
Copy link
Owner

Choose a reason for hiding this comment

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

一般常量用全大写


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;
}




33 changes: 33 additions & 0 deletions level1/p01_runningLetter/L1T4.cpp
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;
}

26 changes: 26 additions & 0 deletions level1/p02_isPrime/L1T2.cpp
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;
}

31 changes: 31 additions & 0 deletions level1/p03_Diophantus/L1T3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### ��̽����������⣺
Copy link
Owner

Choose a reason for hiding this comment

The 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;
}
}
}
15 changes: 15 additions & 0 deletions level1/p04_ narcissus/L1T4.cpp
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);
Copy link
Owner

Choose a reason for hiding this comment

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

注意缩进!
单行代码最好也用大括号抱起来

}
printf("\n");
}
41 changes: 41 additions & 0 deletions level1/p05_allPrimes/L1T5.cpp
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;
}

3 changes: 2 additions & 1 deletion level1/p05_allPrimes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

1. 打印2-1000以内的所有素数
1. 打印出总的计算时间
1. 尽可能优化算法的效率
1. 尽可能优化算法的效率
//
59 changes: 59 additions & 0 deletions level1/p06_Goldbach/L1T6.cpp
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);
Copy link
Owner

Choose a reason for hiding this comment

The 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;
}