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

ruuning letter 完成 #41

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions level1/p01_runningLetter/level1_1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#define WIDTH 20
int main()
{
int x,y,z,s,w;
char a[WIDTH];
for(x=1;x<=100;x++)

{
if (x%2==1)
{
w=1;
}
Copy link
Owner

Choose a reason for hiding this comment

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

缩进不对

else
{
w=-1;
}
{for(y=WIDTH*(1-w)/2;y!=WIDTH*(1+w)/2;y+=w)
Copy link
Owner

Choose a reason for hiding this comment

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

for语句新起一行

{for(z=0;z<y;z++)
Copy link
Owner

Choose a reason for hiding this comment

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

缩进代表代码的层次结构,要重视;
提示:空格和tab不宜混用,因为不同的环境对tab键对应的空格数是不一样的;
ps:比较好一点的IDE,一般都有format工具可以用

{
putchar(' ');
}
printf("%c\n",'A');
Sleep(100);
system("cls");
}
}

}
}
25 changes: 25 additions & 0 deletions level1/p02_isPrime/level1_2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<stdio.h>
#include<math.h>
int main()
{
int x,y,z,w;
w=0;
printf("Plesse input a integer:\n");
scanf("%d",&x);
y=sqrt(x);
for(z=2;z<=y;z++)
{
if((x/z*z)==x)
w=1;
}

if(w!=0)
{
printf("%d is not prime\n",x);
}
else
{
printf("%d is prime\n",x);
}
return 0;
}
11 changes: 11 additions & 0 deletions level1/p03_Diophantus/level1_3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include<stdio.h>
int main()
{
float x;
for(x=4;x<200;x++)
if(x/6+x/12+x/7+5+x/2+4==x)
{
printf("age=%.0f\n",x);
}
return 0;
}
17 changes: 17 additions & 0 deletions level1/p04_ narcissus/level1_4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<stdio.h>
int main()
{
int x,a,b,c;
printf("Narcissistic numbes between 100~999 are as follows:");
for(x=100;x<=999;x++)
{
a=x/100;
b=(x-a*100)/10;
c=x%10;
if(a*a*a+b*b*b+c*c*c==x)
{
printf(" %d",x);
}
}
return 0;
}
25 changes: 25 additions & 0 deletions level1/p05_allPrimes/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<stdio.h>
#include<math.h>
#include<time.h>
#include"prime_under_1000.h"

int main()
{
int i,w;//i from 1 to 1000;w=return value
time_t begin,end;

begin=clock();

printf("2");//other primes are all odd
for(i=3;i<=1000;i+=2)
{
if (prime(i)==0)
{
printf(",%d",i);
}
}

end=clock();
printf("\n\nTime used=%dms",end-begin);
return 0;
}
18 changes: 18 additions & 0 deletions level1/p05_allPrimes/prime_under_1000.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
int prime(int x)
{
int a[]={3,5,7,11,13,17,19,23,29,31,37};//sqrt(1000)<37
int sqrt_x,i,w;

sqrt_x=sqrt(x)+1;
w=0;

for(i=0;a[i]<=sqrt_x;i++)
{
if(x%a[i]==0)
{
w=1;
break;
}
}
return w;
}
24 changes: 24 additions & 0 deletions level1/p06_Goldbach/Goldbach.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
int Goldbach(int x)
{
int a[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int i_1,i_2;
int w=0;

for(i_1=0;i_1<=24;i_1++)
{
for(i_2=0;i_2<=24;i_2++)
{
if(x==a[i_1]+a[i_2])
{
printf("%d=%d+%d\n",x,a[i_1],a[i_2]);
w++;
}
}
}

if(w==0)
{
printf("Goldbach for %d is wrong!",x);
}
}

72 changes: 72 additions & 0 deletions level1/p06_Goldbach/level1_6.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[Project]
FileName=level1_6.dev
Name=��Ŀ3
Type=1
Ver=2
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
IsCpp=1
Icon=
ExeOutput=
ObjectOutput=
LogOutput=
LogOutputEnabled=0
OverrideOutput=0
OverrideOutputName=
HostApplication=
UseCustomMakefile=0
CustomMakefile=
CommandLine=
Folders=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000000000000000000000
UnitCount=2

[VersionInfo]
Major=1
Minor=0
Release=0
Build=0
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0
SyncProduct=1

[Unit1]
FileName=main.c
CompileCpp=1
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

[Unit2]
FileName=Goldbach.h
CompileCpp=1
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

14 changes: 14 additions & 0 deletions level1/p06_Goldbach/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<stdio.h>
#include<math.h>
#include"Goldbach.h"

int main()
{
int i;
for(i=4;i<=100;i+=2)
{
Goldbach(i);
printf("\n");
}
return 0 ;
}
28 changes: 28 additions & 0 deletions level1/p07_encrypt_decrypt/Makefile.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Project: decrypt
# Makefile created by Dev-C++ 5.11

CPP = g++.exe -D__DEBUG__
CC = gcc.exe -D__DEBUG__
WINDRES = windres.exe
OBJ = decrypt.o
LINKOBJ = decrypt.o
LIBS = -L"D:/Dev-Cpp/MinGW64/lib" -L"D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc -g3
INCS = -I"D:/Dev-Cpp/MinGW64/include" -I"D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include"
CXXINCS = -I"D:/Dev-Cpp/MinGW64/include" -I"D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++"
BIN = decrypt.exe
CXXFLAGS = $(CXXINCS) -g3
CFLAGS = $(INCS) -g3
RM = rm.exe -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after

clean: clean-custom
${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)

decrypt.o: decrypt.c
$(CPP) -c decrypt.c -o decrypt.o $(CXXFLAGS)
23 changes: 23 additions & 0 deletions level1/p07_encrypt_decrypt/decrypt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"function_2.h"

int main()
{
char mingwen[200]={0},key[200]={0},miwen[200]={0};
char ch;
int i;

printf("Please input the key\n");
input(key);
printf("Please input what you want to derypt��\n");
input(miwen);

decrypt(key,miwen,mingwen);
printf("mingwen:\n");
output(mingwen);

return 0;

}
72 changes: 72 additions & 0 deletions level1/p07_encrypt_decrypt/decrypt.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[Project]
FileName=decrypt.dev
Name=decrypt
Type=1
Ver=2
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
IsCpp=1
Icon=
ExeOutput=
ObjectOutput=
LogOutput=
LogOutputEnabled=0
OverrideOutput=0
OverrideOutputName=
HostApplication=
UseCustomMakefile=0
CustomMakefile=
CommandLine=
Folders=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=1
CompilerSettings=0000000000000000001000000
UnitCount=2

[VersionInfo]
Major=1
Minor=0
Release=0
Build=0
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0
SyncProduct=1

[Unit2]
FileName=function_2.h
CompileCpp=1
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

[Unit1]
FileName=decrypt.c
CompileCpp=1
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

Binary file added level1/p07_encrypt_decrypt/decrypt.exe
Binary file not shown.
13 changes: 13 additions & 0 deletions level1/p07_encrypt_decrypt/decrypt.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Editors]
Order=0,1
Focused=1
[Editor_0]
CursorCol=2
CursorRow=16
TopLine=1
LeftChar=1
[Editor_1]
CursorCol=40
CursorRow=53
TopLine=32
LeftChar=1
Binary file added level1/p07_encrypt_decrypt/decrypt.o
Binary file not shown.
Loading