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

是这样交作业吗 #25

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
5 changes: 0 additions & 5 deletions C语言学习笔记.md

This file was deleted.

Empty file.
22 changes: 22 additions & 0 deletions level1/p02_isPrime/1-2 isP.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<iostream>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
#include<string.h>

int main(){
int n;
bool pr=1;
cin>>n;
for(int i=2;i<=sqrt(double(n));i++){
if(n%i==0){
pr=0;
}
}
if ((pr)&&(n!=1)){
cout<<"Yes";
}
else{
cout<<"No";
}
}
17 changes: 17 additions & 0 deletions level1/p03_Diophantus/1-3 KonoDioda.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

int main(){
int fth,sn;
for(int i=28;i<=300;i+=28){
fth=i;
sn=fth-fth*11/28-9;
if(fth==sn*2){
cout<<i;
}
}
}
18 changes: 18 additions & 0 deletions level1/p04_ narcissus/1-4 water.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<iostream>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

int main(){
int a,b,c;
for(int i=100;i<=999;i++){
a=i/100;
b=(i/10)%10;
c=i%10;
if(pow(a,3)+pow(b,3)+pow(c,3)==i){
cout<<i<<endl;
}
}
}
25 changes: 25 additions & 0 deletions level1/p05_allPrimes/1-5 AllPrimes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<iostream>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<windows.h>
using namespace std;

int main(){
int a[1000]={0};
long op,ed;
op=clock();
a[1]=1;
for(int i=2;i<=997;i++){
if(a[i]==0){
for(int j=i*i;j<=1000;j+=i){
a[j]=1;
}
cout<<i<<endl;
}
}
ed=clock();
cout<<"time="<<ed-op;
}
57 changes: 57 additions & 0 deletions level1/p06_Goldbach/Goldbahe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include<iostream>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include<windows.h>
using namespace std;

int Prime[50]={0};
int t=0;
int a[100]={0};

void FindPrime(){
a[1]=1;
for(int i=2;i<=97;i++){
if(a[i]==0){
for(int j=i*i;j<=100;j+=i){
a[j]=1;
}
Prime[t]=i;
t++;
}
}
}

int main(){
bool gede,bahe;
int now;
FindPrime();
bahe=1;
for(int i=6;i<=100;i+=2){
now=1;
gede=1;
while(Prime[now]<=i/2){
if(a[i-Prime[now]]==0){
gede=0;
break;
}
now++;
}
if(gede){
bahe=0;
break;
}
}
if(bahe){
cout<<"Yes";
}
else{
cout<<"No!What happened??";
}
return 0;
}



38 changes: 38 additions & 0 deletions level1/p07_encrypt_decrypt/string.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include<iostream>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

void encrypt(char *s){
int len;
char chu;
chu=s[0];
len=strlen(s);
for(int i=0;i<len-1;i++){
s[i]=s[i+1];
}
s[len-1]=chu;
}

void decrypt(char *s){
int len;
char mo;
len=strlen(s);
mo=s[len-1];
for(int i=len-1;i>=1;i--){
s[i]=s[i-1];
}
s[0]=mo;
}

int main(){
char st[1000];
cin>>st;
encrypt(st);
cout<<st<<endl;
decrypt(st);
cout<<st;
return 0;
}
Binary file removed level1/p08_hanoi/hanoi.jpg
Binary file not shown.
24 changes: 24 additions & 0 deletions level1/p08_hanoi/hanot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<iostream>
#include<cstdio>
#include<math.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

void hano(int gs,int st,int fi,int be){
if(gs==1){
cout<<gs<<":"<<st<<" - "<<fi<<endl;
}
else{
hano(gs-1,st,be,fi);
cout<<gs<<":"<<st<<" - "<<fi<<endl;
hano(gs-1,be,fi,st);
}
}

int main(){
int n;
cin>>n;
hano(n,1,3,2);
return 0;
}
Loading