diff --git a/0.txt b/0.txt new file mode 100644 index 00000000..baec051b --- /dev/null +++ b/0.txt @@ -0,0 +1,11 @@ +9 9 +0 0 0 0 0 0 0 0 0 +3 1 1 1 1 1 1 1 0 +0 1 1 1 1 1 1 1 0 +0 1 1 1 2 1 1 1 0 +0 1 1 1 1 1 1 1 0 +0 1 1 1 1 1 1 1 0 +0 1 1 1 1 1 1 1 0 +0 1 1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 + diff --git a/List.txt b/List.txt new file mode 100644 index 00000000..947c19da --- /dev/null +++ b/List.txt @@ -0,0 +1,4 @@ +3 +a 1444 +b 600 +c 99 diff --git a/p01_runningLetter.cpp b/p01_runningLetter.cpp new file mode 100644 index 00000000..fa26bb92 --- /dev/null +++ b/p01_runningLetter.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +int cnt; +bool flag; +int main() +{ + while(1) + { + if(cnt==120) flag=1; + if(cnt==0) flag=0; + cout< +using namespace std; +int n; +int main() +{ + cin>>n; + int m=(int)sqrt(n)+1; + for(int i=2;i +using namespace std; +int main() +{ + for(float i=1;;i++) + { + if(i/6+i/12+i/7+5+4==i/2) + { + cout< +using namespace std; +int cub(int x) +{ + return x*x*x; +} +bool nar(int x) +{ + int sum=0; + int sum0=x; + while(x>0) + { + sum+=cub(x%10); + x/=10; + } + return sum==sum0; +} +int main() +{ + for(int i=100;i<=999;i++) + { + if(nar(i)) cout< +#include +using namespace std; +int main() +{ + int isprime[1000]; + for(int i=0;i<=1000;i++) + { + isprime[i]=1; + } + for(int i=2;i<=1000;i++) + { + if(isprime[i]==1) + { + cout< +using namespace std; +int n,p[25]={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},r[3]; +void dfs(int x,int s) +{ + if(s>3) return; + else if(x==n && s==3 && r[0]<=r[1] && r[1]<=r[2]) + { + cout<>n; + if(n<=5 || n>100) cout<<"error"< +#include +#include +using namespace std; +string w,mp="qazxswedcvfrtgbnhyujmkiolp"; +void enc(void) +{ + for(int i=0;i>w; + for(int i=0;i122) + { + cout< +using namespace std; +void hano(int n,char a,char b,char c)//n是准备移动的块数,a是起始柱,b是中间柱,c是目标柱; +{ + if(n==0) return; + hano(n-1,a,c,b);//先将第n个盘子上的n-1个盘子从a移到b; + printf("将第%d号盘子从%c柱移动到%c柱\n",n,a,c); + hano(n-1,b,c,a);//再将n-1个盘子从b移到c,完成任务; +} +int main() +{ + cout<<"请输入盘子总数:"; + int n; + cin>>n; + hano(n,'A','B','C'); + return 0; +} diff --git a/p09_maze.cpp b/p09_maze.cpp new file mode 100644 index 00000000..4888baaa --- /dev/null +++ b/p09_maze.cpp @@ -0,0 +1,110 @@ +//此程序的地图是用深度优先搜素算法(dfs)随机生成的! +#include +#include +using namespace std; +int xx[]={1,-1,0,0},yy[]={0,0,1,-1},v[44][44],mp[44][44]; +struct Node +{ + int nx,ny; +}nod; +void dfs(int x,int y) +{ + mp[x][y]=1; + if(x==1 && y==1) return; + int s=rand()%4; + for(int i=s;i0 && dy>0 && dx<43 && dy<43 && v[dx][dy]==0) + { + int flag=0; + for(int k=0;k<4;k++) + { + int ddx=dx+xx[k]; + int ddy=dy+yy[k]; + if(mp[ddx][ddy]==1) flag++; + } + if(flag==1)//保证不和别的路挖穿,增加迷宫难度; + { + v[dx][dy]=1; + dfs(dx,dy); + } + } + else v[dx][dy]=1; + } +} +int main() +{ + for(int i=0;i<44;i++) + { + for(int j=0;j<44;j++) mp[i][j]=0; + } + dfs(42,42); + mp[1][0]=2; + mp[42][43]=1; + for(int i=0;i<44;i++) + { + for(int j=0;j<44;j++) + { + if(mp[i][j]==1) cout<<" "; + else if(mp[i][j]==0) cout<<"口"; + else if(mp[i][j]==2) cout<<"人"; + } + cout< +#include +#include +using namespace std; +char c; +int n,m,mp[50][50],cnt,xx[]={1,-1,0,0},yy[]={0,0,1,-1}; +struct Node +{ + int nx,ny; +}nod; +int main() +{ + while(1) + { + cout<<"欢迎来到推箱子小游戏"<='0' && c<='9') + { + system("cls"); + break; + } + else cout<<"error"<=0 && dy>=0 && dx +using namespace std; +struct Node +{ + int key; + Node*next; +}; +void append(Node*head,Node*newnode) +{ + Node*p; + p=head; + while(1) + { + if(p->next==NULL) + { + p->next=newnode; + break; + } + p=p->next; + } +} +void _delete(int n,Node*head) +{ + Node*p,*q; + p=q=head;//不要忘记初始化; + for(int i=1;inext; + if(inext; + } + q->next=p->next; + free(p); +} +void insert(int n,Node*head,Node*newone)//指插入在第n位的后面 ; +{ + Node*p=head; + for(int i=1;inext; + } + newone->next=p->next; + p->next=newone; +} +Node*reverse(Node*head) +{ + Node*n,*p,*q; + n=head; + p=head->next; + if(p==NULL) return head; + q=p->next; + while(p!=NULL) + { + p->next=n; + n=p; + p=q; + if(q!=NULL) q=q->next; //不能让q“越界”; + } + head->next=NULL; + return n; +} +int main() +{ + Node*head; + head=(Node*)malloc(sizeof(Node)); + if(head==NULL) + { + cout<<"error"<>v; + *head=(Node){v,NULL}; + while(1) + { + cin>>v; + if(v==-1) break; + Node*p; + p=(Node*)malloc(sizeof(Node)); + if(p==NULL) + { + cout<<"error"<key<<" "; + p=p->next; + } + cout<key<<" "; + p=p->next; + } + cout<key==5) + { + cout<next; + } + if(flag==0) cout<<-1<key<next; + } */ + +/*用于测试insert函数 + Node*t; + int m; + t=(Node*)malloc(sizeof(Node));//不要忘了用malloc给t分配内存! + cin>>m>>v; + *t=(Node){v,NULL}; + insert(m,head,t); + p=head; + while(p!=NULL) + { + cout<key<next; + } */ + +//接下来是释放所有用malloc请求的内存 + p=head; + while(p!=NULL) + { + Node*q=p->next; + free(p); + p=q; + } + return 0; +} diff --git a/p12_warehouse.cpp b/p12_warehouse.cpp new file mode 100644 index 00000000..75a10b8b --- /dev/null +++ b/p12_warehouse.cpp @@ -0,0 +1,135 @@ +#include +#include +#include +using namespace std; +int n; +struct stuff +{ + char name[21]; + int num; +}a[10001]; +void dispaly() +{ + printf("ڿⷿڹ%dֻ\n",n); + for(int i=0;i