-
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
all #49
Open
NONOThingC
wants to merge
8
commits into
luckymark:master
Choose a base branch
from
NONOThingC: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
all #49
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
43f9ea3
homework level1 complete
NONOThingC b7ef4ea
Merge branch 'master' of https://github.com/NONOThingC/c2019
NONOThingC d9a4680
b6045c4
PI float precision is not so well
NONOThingC 6669157
forget time
NONOThingC 0435043
根据要求修改了代码,部分题由于用了STL无法改成c要求的格式了...
NONOThingC ef4660b
level 1 completed,fix bug,delete redundancy file
NONOThingC 2934f29
五子棋程序
NONOThingC 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
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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,45 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <Windows.h> | ||
#define SCREENLENGTH 10 | ||
#define SLEEPTIME 300 //if you can't see the letter move,please modify this number. | ||
void PrintSpace(int n) //enter the amount of space. | ||
{ | ||
for (int i = 0; i < n; i++) | ||
{ | ||
printf(" "); | ||
} | ||
} | ||
int main() | ||
{ | ||
while (1) | ||
{ | ||
int j = 0; | ||
int TempForDection = 0; | ||
while (j >= 0 && j <= SCREENLENGTH) //Condition is very clear. | ||
{ | ||
|
||
PrintSpace(j); | ||
printf("S"); | ||
if (TempForDection == 0) | ||
{ | ||
j++; | ||
} | ||
if (TempForDection == 1) | ||
{ | ||
j--; | ||
} | ||
if (j == SCREENLENGTH) | ||
{ | ||
TempForDection = 1; | ||
} | ||
if (j == 0) | ||
{ | ||
TempForDection = 0; | ||
} | ||
Sleep(SLEEPTIME); | ||
system("cls"); | ||
} | ||
} | ||
return 0; | ||
} |
Empty file.
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,38 @@ | ||
#include <stdio.h> | ||
#define MAX_RANGE /*(2 << 29 - 1)*/ 100000 | ||
int main() | ||
{ | ||
int n; | ||
int funCode = 1; //zero is allPrimes,one is isPrime | ||
while (scanf("%d", &n) == 1 && n > 1) | ||
{ | ||
int A[MAX_RANGE] = {0}; //Use zero to represent this is a prime.Use one to represent this is a prime. | ||
int num = 0; | ||
int TempOfPrime[MAX_RANGE]; | ||
for (int i = 2; i <= n; i++) | ||
{ | ||
if (!A[i]) | ||
{ | ||
num += 1; | ||
TempOfPrime[num] = i; //Attention:First element is a[1] | ||
} | ||
for (int j = 1; j <= num&&i*TempOfPrime[j]<=n; j++) | ||
{ | ||
A[i * TempOfPrime[j]] = 1; | ||
if ((i % TempOfPrime[j])==0) | ||
break; | ||
} | ||
} | ||
if (!funCode) | ||
{ | ||
for (int i = 2; i <= n; i++) | ||
if (!A[i]) | ||
printf("%d ", i); | ||
} | ||
else | ||
{ | ||
|
||
(!A[n]) ? printf("%d is prime ", n) : printf("%d is not prime ", n); | ||
} | ||
} | ||
} |
Empty file.
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,9 @@ | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int i=0; | ||
for(;i<100;i++) | ||
if((1*12*7/6*i+1*12*7/12*i+1*12*7/7*i+5*12*7+1*12*7/2*i+4*12*7)==i*12*7) | ||
break; | ||
printf("His age is :%d",i); | ||
} |
Empty file.
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,28 @@ | ||
#include <stdio.h> | ||
void getThreeDigitNumber(const int targetnumber,int *digit_number) | ||
{ | ||
int i=targetnumber; | ||
int j=0; | ||
while(i) | ||
{ | ||
digit_number[j++]=i%10; | ||
i/=10; | ||
} | ||
} | ||
int main() | ||
{ | ||
int digit_number[3]; | ||
for(int i=100;i<1000;i++) | ||
{ | ||
int sum=0; | ||
get_threeDigit_Number(i,digit_number); | ||
for(int j=0;j<3;j++) | ||
{ | ||
sum+=digit_number[j]*digit_number[j]*digit_number[j]; | ||
} | ||
if(sum==i){ | ||
printf("%d ",i); | ||
} | ||
} | ||
return 0; | ||
} |
Empty file.
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> | ||
#define MAX_RANGE /*(2 << 29 - 1)*/ 100000 | ||
#include <time.h> | ||
int main() | ||
{ | ||
clock_t t1 = clock(); | ||
int n; | ||
int funCode = 0; //zero is allPrimes,one is isPrime | ||
while (scanf("%d", &n) == 1 && n > 1) | ||
{ | ||
int A[MAX_RANGE] = {0}; //Use zero to represent this is a prime.Use one to represent this is a prime. | ||
int num = 0; | ||
int TempOfPrime[MAX_RANGE]; | ||
for (int i = 2; i <= n; i++) | ||
{ | ||
if (!A[i]) | ||
{ | ||
num += 1; | ||
TempOfPrime[num] = i; //Attention:First element is a[1] | ||
} | ||
for (int j = 1; j <= num&&i*TempOfPrime[j]<=n; j++) | ||
{ | ||
A[i * TempOfPrime[j]] = 1; | ||
if ((i % TempOfPrime[j])==0) | ||
break; | ||
} | ||
} | ||
|
||
if (!funCode) | ||
{ | ||
for (int i = 2; i <= n; i++) | ||
if (!A[i]) | ||
printf("%d ", i); | ||
} | ||
else | ||
{ | ||
|
||
(!A[n]) ? printf("%d is prime ", n) : printf("%d is not prime ", n); | ||
} | ||
clock_t t2 = clock(); | ||
printf("Execution time is: %fs\n", double(t2-t1)/CLOCKS_PER_SEC); | ||
} | ||
} |
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,53 @@ | ||
#include <cstdio> | ||
#include <set> | ||
#define MAX_RANGE /*(2 << 29 - 1)*/ 100000 | ||
using namespace std; | ||
int main() | ||
{ | ||
const int n=101;//The range of number you want to prove | ||
set<int> storage_Prime; | ||
|
||
int A[MAX_RANGE] = {0}; //Use zero to represent this is a prime.Use one to represent this is a prime. | ||
int num = 0; | ||
//generate Prime | ||
int TempOfPrime[MAX_RANGE]; | ||
for (int i = 2; i <= n; i++) | ||
{ | ||
if (!A[i]) | ||
{ | ||
num += 1; | ||
TempOfPrime[num] = i; //Attention:First element is a[1] | ||
} | ||
for (int j = 1; j <= num && i * TempOfPrime[j] <= n; j++) | ||
{ | ||
A[i * TempOfPrime[j]] = 1; | ||
if ((i % TempOfPrime[j]) == 0) | ||
break; | ||
} | ||
for (int i = 2; i <= n; i++) | ||
{ | ||
if (!A[i]) | ||
{ | ||
storage_Prime.insert(i); | ||
} | ||
} | ||
} | ||
for(int i=4;i<n;i+=2) | ||
{ | ||
int flag=1;//有问题 | ||
for(set<int>::const_iterator citer=storage_Prime.begin();(*citer)<=i&&citer!=storage_Prime.end();citer++) | ||
{ | ||
int remainder=i-*citer; | ||
if(storage_Prime.find(remainder) != storage_Prime.end())//If find in Prime Set | ||
{ | ||
flag=0;// | ||
} | ||
} | ||
if(flag) | ||
{ | ||
printf("Goldbach is not right."); | ||
return 0; | ||
} | ||
} | ||
printf("Goldbach is right."); | ||
} |
Empty file.
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,66 @@ | ||
#include "pch.h" | ||
#include "Huffman.h" | ||
void HuffmanCoding(HNode *HT, HCode *HC, unsigned long long *w, const int n) | ||
{ | ||
//初始化 | ||
int m = 2 * n - 1; | ||
HNode *p = HT; | ||
int i = 0; | ||
//听取俸爷建议,重构此处代码 | ||
for (; i < n+m; i++, p++) | ||
{ | ||
if (i >= n) | ||
{ | ||
p->weight = 0; | ||
} | ||
else | ||
{ | ||
p->weight = *w; | ||
w++; | ||
} | ||
p->lchild = -1; | ||
p->rchild = -1; | ||
p->parent = -1; | ||
} | ||
//构造HUFFMAN TREE | ||
for (i = n; i < m; i++) | ||
{ | ||
long long min1 = MAXVALUE, min2 = MAXVALUE; | ||
int min1id = 0, min2id = 0; //min1是最小的,min2次小 | ||
for (int j = 0; j < i; j++) | ||
{ | ||
if (HT[j].parent == -1 && HT[j].weight < min1) | ||
{ | ||
min2 = min1; | ||
min2id = min1id; | ||
min1 = HT[j].weight; | ||
min1id = j; | ||
} | ||
else if (HT[j].parent == -1 && HT[j].weight < min2) | ||
{ | ||
min2 = HT[j].weight; | ||
min2id = j; | ||
} | ||
} | ||
HT[min1id].parent = i; | ||
HT[min2id].parent = i; | ||
HT[i].lchild = min1id; | ||
HT[i].rchild = min2id; | ||
HT[i].weight = min1 + min2; | ||
} | ||
//做字符编码 | ||
for (int j = 0; j < n; j++) | ||
{ | ||
int start = n - 1; | ||
for (int tempid = j, tempparent = HT[j].parent; tempparent != -1; tempid = tempparent, tempparent = HT[tempparent].parent) | ||
{ | ||
if (HT[tempparent].lchild == tempid) | ||
{ | ||
HC[j].bit[start--] = 0; | ||
} | ||
else | ||
HC[j].bit[start--] = 1; | ||
} | ||
HC[j].start = start + 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,14 @@ | ||
#pragma once | ||
#define MAXBIT 256 | ||
const long long MAXVALUE = 9223372036854775806; | ||
typedef struct HNode { | ||
long long weight; | ||
int parent; | ||
int lchild; | ||
int rchild; | ||
} HNode; | ||
typedef struct HCode { | ||
int bit[MAXBIT]; | ||
int start; | ||
} HCode; | ||
void HuffmanCoding(HNode *HT, HCode *HC, unsigned long long *w, const int 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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
### 功能要求: | ||
|
||
1. 分别编写“加密”、“解密”函数,输入为任意长度的字符串 | ||
<<<<<<< HEAD | ||
1. 分别编写“加密”、“解密”函数,输入为任意长度的字符串 | ||
|
||
|
||
MY program:Huffman encoding.This program can deal with any format below 4GB. | ||
|
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.
与其写一个注释来说明,不如提取为一个函数,再给它个好名字