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

2018081309027陶奕兮 #44

Open
wants to merge 15 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
33 changes: 33 additions & 0 deletions .gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
5 changes: 5 additions & 0 deletions level0/C01.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include<stdio.h>
int main()
{
printf("Hello world!I'm tyx!");
}
12 changes: 12 additions & 0 deletions level0/C11.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<stdio.h>
int main()
{
int n;
printf("Please put in a number:\n");
scanf("%d",&n);
if(n%2==0) printf("It's an even number.\n");
else printf("It's an odd number.\n");
if(n>0) printf("It's a positive number.\n");
else if(n==0) printf("It's zero.\n");
else printf("It's a negative number.\n");
}
9 changes: 9 additions & 0 deletions level0/C12.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<stdio.h>
int main()
{
int n;
printf("Please put in a number:\n");
scanf("%d",&n);
if(n%13==0) printf("Yes.\n");
else printf("No.\n");
}
21 changes: 21 additions & 0 deletions level0/C210.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include<stdio.h>
int main()
{
int b[5],c[10]={0};
printf("Please put in 5 numbers(between 0-9):\n");
for(int i=0;i<5;i++)
{
scanf("%d",&b[i]);
for(int t=0;t<10;t++)
{
if(b[i]==t) c[t]++;
}
}
for(int t=0;t<10;t++)
{
for(int i=1;i<=c[t];i++)
{
printf("%d,",t);
}
}
}
10 changes: 10 additions & 0 deletions level0/C22.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include<stdio.h>
#include<stdlib.h>
int main()
{
system("color 0a");
while(1)
{
printf("0 1");
}
}
10 changes: 10 additions & 0 deletions level0/C23.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include<stdio.h>
#include<stdlib.h>
int main()
{
system("color 0a");
while(1)
{
printf("%d\t",rand()/1000);
}
}
20 changes: 20 additions & 0 deletions level1/p01_runningLetter/lv1_p01.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,wide=80;
bool turn;
for(i=0;;)
{
for(int t=0;t<=i;t++)
{
printf(" ");
}
printf("R");
system("cls");
if(i==wide) turn=1;
if(i<0) turn=0;
if(turn==0) i++;
else i--;
}
}
18 changes: 18 additions & 0 deletions level1/p02_isPrime/lv1_p02.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<stdio.h>
int main()
{
int n,ans=0;
printf("Please input a positive integer:\n");
scanf("%d",&n);
for(int t=2;t<=n/2;t++)
{
if(n%t==0)
{
ans=1;
break;
}
}
if(ans==1) printf("It's not a prime number.");
else printf("It's a prime number.");
return 0;
}
12 changes: 12 additions & 0 deletions level1/p03_Diophantus/lv1_p03.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<stdio.h>
int main()
{
for(int age=1;;age++)
{
if(age/6+age/12+age/7+5+age/2+4==age)
{
printf("%d",age-4);
break;
}
}
}
16 changes: 16 additions & 0 deletions level1/p04_ narcissus/lv1_p04.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include<stdio.h>
int main()
{
int x,g,s,b;
for(x=100;x<=999;x++)
{
g=x%10;
s=((x-g)/10)%10;
b=(x-g-s)/100;
if(x==g*g*g+s*s*s+b*b*b)
{
printf("%d��",x);
}
}
getchar();
}
17 changes: 17 additions & 0 deletions level1/p05_allPrimes/lv1_p05.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<stdio.h>
#include<time.h>
int main()
{
long t1,t2;
t1=clock();
for(int n=2;n<=1000;n++)
{
for(int t=2;t<=n/2+1;t++)
{
if(t==n/2+1) printf("%d,",n);
if(n%t==0) break;
}
}
t2=clock();
printf("\nTotally used %ld ms.\n",(t2-t1));
}
37 changes: 37 additions & 0 deletions level1/p06_Goldbach/lv1_p06.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include<stdio.h>
int is_p(int x)
{
for(int i=2;i<=x/2+1;i++)
{
if(i==x/2+1) return 1;
if(x%i==0)
{
return 0;
break;
}
}
}

int main()
{
int prime;
for(int t=4;t<101;t=t+2)
{
int m=2,n;
for(;;)
{
prime=is_p(m);
if(prime==1)
{
n=t-m;
prime=is_p(n);
if(prime==1)
{
printf("%d=%d+%d\n",t,m,n);
break;
}
}
m++;
}
}
}
117 changes: 117 additions & 0 deletions level1/p07_encrypt_decrypt/lv1_p07.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

char sentence[1000], enc[3][334], decr[1000];

//����IJ���������˵��RSA�����㷨ɶ�ġ�����Ū��һ��������λ����+����դ������Ȼ��˵դ�����ʺ��������ܳ����ַ����ļ���
//dbq�һ���ûŪ����ô���ļ����¸���ҵ����

void encrypt()
{
int line = 0, row = 0;
cout << "����ģʽ/��������Ҫ���ܵ��ַ����������ո񣩣�" << endl;
cin >> sentence;
for (int i = 0; sentence[i] != '\0'; i++)
{
enc[row][line] = sentence[i] + 3;
if (row == 2)
{
row = 0;
line++;
continue;
}
row++;
}
for (row = 0; row < 4; row++)
{
printf("%s", enc[row]);
}
printf("\n");
return;
}

void decrypt()//error
{
int line = 0, row = 0, ex_row = 0, count = 0,line_num=0;
cout << "����ģʽ/�������ø÷�ʽ���ܵ��ַ����������ո񣩣�" << endl;
cin >> sentence;
for (count;; count++)
{
if (sentence[count] == '\0')
{
ex_row = count % 3;
line_num = (count/3);
break;
}
}
for (int i = 0; i != count; i++)
{
enc[row][line] = sentence[i] - 3;
if (ex_row == 0)
{
if (line == line_num - 1)
{
line = 0;
row++;
}
else line++;
}
else if (ex_row == 1)
{
if (row == 0)
{
if (line == line_num)
{
line = 0;
row++;
}
else line++;
}
else
{
if (line == line_num-1)
{
line = 0;
row++;
}
else line++;
}
}
else if (ex_row == 2)
{
if (line == line_num)
{
line = 0;
row++;
}
else line++;
}
}
for (line = 0; line <= line_num; line++)
{
for (row = 0; row < 3; row++)
{
printf("%c", enc[row][line]);
}
}
printf("\n");
return;
}

int main()
{
int choose;
while (1)
{
memset(sentence, 0, sizeof sentence);
memset(enc, 0, sizeof enc);
memset(decr, 0, sizeof decr);
cout << "��1�������ģʽ����2�������ģʽ����0�˳���" << endl;
cin >> choose;
if (choose == 1) encrypt();
if (choose == 2) decrypt();
if (choose == 0) break;
}
}
Binary file added level1/p08_hanoi/lv1_p08/.vs/lv1_p08/v15/.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added level1/p08_hanoi/lv1_p08/Debug/lv1_p08.exe
Binary file not shown.
Binary file added level1/p08_hanoi/lv1_p08/Debug/lv1_p08.ilk
Binary file not shown.
Binary file added level1/p08_hanoi/lv1_p08/Debug/lv1_p08.pdb
Binary file not shown.
31 changes: 31 additions & 0 deletions level1/p08_hanoi/lv1_p08/lv1_p08.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lv1_p08", "lv1_p08\lv1_p08.vcxproj", "{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}.Debug|x64.ActiveCfg = Debug|x64
{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}.Debug|x64.Build.0 = Debug|x64
{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}.Debug|x86.ActiveCfg = Debug|Win32
{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}.Debug|x86.Build.0 = Debug|Win32
{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}.Release|x64.ActiveCfg = Release|x64
{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}.Release|x64.Build.0 = Release|x64
{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}.Release|x86.ActiveCfg = Release|Win32
{0E7B9FF8-AEBD-472A-9ABC-C054F666FE70}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {522FA77D-5922-4F7E-9B8F-3FE0F64AF89E}
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions level1/p08_hanoi/lv1_p08/lv1_p08/Debug/lv1_p08.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
 move.cpp
lv1_p08.vcxproj -> C:\编程试水\作业\汉诺塔\lv1_p08\Debug\lv1_p08.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.16299.0
Debug|Win32|C:\编程试水\作业\汉诺塔\lv1_p08\|
Binary file added level1/p08_hanoi/lv1_p08/lv1_p08/Debug/main.obj
Binary file not shown.
Binary file not shown.
Binary file added level1/p08_hanoi/lv1_p08/lv1_p08/Debug/vc141.idb
Binary file not shown.
Binary file added level1/p08_hanoi/lv1_p08/lv1_p08/Debug/vc141.pdb
Binary file not shown.
Loading