-
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
Open
C-ice-y
wants to merge
35
commits into
luckymark:master
Choose a base branch
from
C-ice-y:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
bec1370
完成了running letter
3f73640
Level 1 Exercise 2
C-ice-y 2ac63b7
Level 1Exercise 3
C-ice-y bf75807
Level 1 Exercise 4
C-ice-y e26d96d
Level1 Exercise 1 update
C-ice-y 5f014e1
level1 Exercise5
C-ice-y 2356fcb
Update README.md
C-ice-y 4cdf1fc
Level1 Exercise6
C-ice-y bd24ae4
Update L1T4.cpp
C-ice-y 1ec64ee
Update L1T5.cpp
C-ice-y 9da8788
Update L1T3.cpp
C-ice-y 549129c
Exercise L1T8
C-ice-y 5f1fe82
Update README.md
C-ice-y 3f3305a
Add files via upload
C-ice-y 7e340fa
Add files via upload
C-ice-y d214aba
Add files via upload
C-ice-y dc210c8
Add files via upload
C-ice-y 2b737f7
Create FiveChess
C-ice-y 2530e96
Delete FiveChess
C-ice-y c9d8dfc
Add files via upload
C-ice-y da9cf3b
Delete 五子棋txt.txt
C-ice-y fbcfb3e
Delete thoughts of WUZIQI.txt
C-ice-y d3243b1
Add files via upload
C-ice-y ad0faa3
Add files via upload
C-ice-y 244422f
Delete mazeutf.txt
C-ice-y 67c075d
Add files via upload
C-ice-y 517d040
Delete 推箱子utf.txt
C-ice-y da4f9c9
Add files via upload
C-ice-y 9412054
Delete 链表.txt
C-ice-y 9fae957
Add files via upload
C-ice-y 650d8d0
Delete utf超市.txt
C-ice-y ad232b9
Add files via upload
C-ice-y d3ec29a
Add files via upload
C-ice-y 07311d7
Update 五子棋txt.txt
C-ice-y a8d0c59
Update 五子棋txt.txt
C-ice-y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
|
||
#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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#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); | ||
} | ||
} | ||
printf("\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
1. 打印2-1000以内的所有素数 | ||
1. 打印出总的计算时间 | ||
1. 尽可能优化算法的效率 | ||
1. 尽可能优化算法的效率 | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* 我用的凯撒加密*/ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
//函数encrypt()将字母顺序推后n位,实现文件加密功能 | ||
void encrypt(char str[],int n) | ||
{ | ||
char c; | ||
int i; | ||
for(i=0;i<strlen(str);++i) | ||
{ | ||
c=str[i]; | ||
if(c>='a' && c<='z')//c是小写字母 | ||
{ | ||
if(c+n%26<='z') //若加密后不超出小写字母范围 | ||
{ | ||
str[i]=(char)(c+n%26); //加密函数 | ||
} | ||
else | ||
{ | ||
str[i]=(char)(c+n%26-26);//加密后超出小写字母范围,从头开始循环小写字母 | ||
} | ||
} | ||
else if(c>='A' && c<='Z')//c为大写字母 | ||
{ | ||
if(c + n%26 <= 'Z') //加密后不超出大写字母范围 | ||
{ | ||
str[i]=(char)(c+n%26); | ||
} | ||
else | ||
{ | ||
str[i]=(char)(c+n%26-26);//加密后超出大写字母范围,从头开始循环大写字母 | ||
} | ||
} | ||
else | ||
{ | ||
str[i]=c;//不是字母,不加密 | ||
} | ||
} | ||
printf("\nAfter encrypt: \n"); | ||
puts(str); //输出加密后的字符串 | ||
} | ||
|
||
|
||
//decrypt()实现解密功能,将字母顺序前移n位 | ||
void decrypt(char str[],int n) | ||
{ | ||
char c; | ||
int i; | ||
//遍历字符串 | ||
for(i=0;i<strlen(str);++i) | ||
{ | ||
c=str[i]; //c为小写字母 | ||
if(c>='a' && c<='z') | ||
{ | ||
|
||
if(c-n%26>='a') //解密后还为小写字母,直接解密 | ||
{ | ||
str[i]=(char)(c-n%26); | ||
} | ||
else | ||
{ | ||
|
||
str[i]=(char)(c-n%26+26); //解密后不为小写字母了,通过循环小写字母处理为小写字母 | ||
} | ||
} | ||
else if(c >= 'A' && c<='Z') //c为大写字母 | ||
{ | ||
if(c-n%26>='A') //解密后还为大写字母 | ||
{ | ||
str[i]=(char)(c-n%26); | ||
} | ||
else | ||
{ | ||
str[i]=(char)(c-n%26+26); //解密后不为大写字母了,循环大写字母,处理为大写字母 | ||
} | ||
else | ||
{ | ||
str[i]=c; //非字母不处理 | ||
} | ||
} | ||
printf("\nAfter decrypt: \n"); | ||
puts(str); //输出解密后的字符串 | ||
} | ||
|
||
int main() | ||
{ | ||
char str[50]; | ||
int k=0,n=0,i=1; | ||
printf("\nPlease input strings: "); | ||
scanf("%s",str); //输入加密解密字符串 | ||
//打印菜单 | ||
printf("-----------------\n"); | ||
printf("1: Encryption\n"); | ||
printf("2: Decryption\n"); | ||
printf("3: Violent Crack\n"); //暴力破解 | ||
printf("-----------------\n"); | ||
printf("\nPlease choose: "); | ||
scanf("%d",&k); | ||
if(k==1) | ||
{ | ||
printf("\nPlease input number: "); | ||
scanf("%d",&n); | ||
encrypt(str,n); | ||
} | ||
else if(k==2) | ||
{ | ||
printf("\nPlease input number: "); | ||
scanf("%d",&n); | ||
decrypt(str,n); | ||
} | ||
else | ||
{ | ||
for(i=1;i<=25;++i) | ||
{ | ||
printf("%d ",i); //尝试所有可能的n值进行暴力破解 | ||
decrypt(str,i); | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
一般常量用全大写