- 博客(29)
- 收藏
- 关注
原创 英杰们的蛋糕塔
#include <iostream>#include <cmath>using namespace std;int V, N, res = 1000000;int mins[21] = {0}, minv[21] = {0};void cake(int pos, int r, int h, int v, int s) { //剪枝 if(v > V || s >= res) return; if((V - v) * 2 /...
2022-04-29 18:26:16
723
原创 小猫爬山(深搜)
尝试每只猫的所有放法:放在已有的可以放下的车子里或放在新车子#include <iostream>#include <algorithm>using namespace std;int N, W, cat[18], res, car[18] = {0};void judge(int ct, int cr) { //剪枝 if(cr > res) return; //所有猫都放下了 if(ct == N) { ...
2022-04-27 17:53:47
392
原创 海拉鲁城堡问题
#include <iostream>using namespace std;int m, n, num[50][50];int judge(int x, int y) { //判断边界 if(x < 0 || x >= m || y < 0 || y >= n || num[x][y] == -1) return 0; int pos[4], res = 1, temp = num[x][y]; //化为二进制 ...
2022-04-24 09:14:06
202
原创 骑士林克的怜悯
#include <iostream>using namespace std;int p, q;char resx[26], resy[26];int dy[8] = {-2, -2, -1, -1, 1, 1, 2, 2}, dx[8] = {-1, 1, -2, 2, -2, 2, -1, 1};//判断该点是否走过int judge(int x, int y, int pos) { for (int i = 0; i <= pos; i++)...
2022-04-19 10:10:57
1134
原创 净化迷雾森林
#include<iostream>using namespace std;char ch[20][20];int W, H, dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};int choice (int r, int l) { int res = 1; //净化该点 ch[r][l] = '#'; //向四个方向搜索 for (int i = 0; i < 4; i++) {...
2022-04-19 10:09:16
276
原创 汉诺塔(递归)
有三根杆子A,B,C。A杆上有N个(N>1)穿孔圆盘,盘的尺寸由下到上依次变小。要求按下列规则将所有圆盘移至C杆: 每次只能移动一个圆盘; 大盘不能叠在小盘上面。 提示:可将圆盘临时置于B杆,也可将从A杆移出的圆盘重新移回A杆,但都必须遵循上述两条规则。
2022-03-09 17:32:09
144
原创 藏头诗(中文字符的输入输出)
中文字符以ASCII的字符串形式储存一个中文字符占两个字节连续两个大于127的字符认为是一个中文字符#include <stdio.h>int main(){ char poem[4][15]; for (int i = 0; i < 4; i++) { gets(poem[i]); poem[i][2] = 0; } for (int i = 0; i < 4; i++) printf(...
2021-12-20 11:33:13
276
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人