更新部分代码
This commit is contained in:
parent
bfebfc9c4a
commit
34375a6457
|
@ -1 +1,2 @@
|
||||||
*.exe
|
*.exe
|
||||||
|
.vscode/*
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include <conio.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define MAX_COLUMN 20
|
||||||
|
#define MAX_ROW 20
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int current_width;
|
||||||
|
int current_height;
|
||||||
|
int column_width[MAX_COLUMN];
|
||||||
|
int row_height[MAX_ROW];
|
||||||
|
|
||||||
|
} TableInfo;
|
||||||
|
|
||||||
|
void init_table(int width, int height, TableInfo *table) {
|
||||||
|
table->current_width = width;
|
||||||
|
table->current_height = height;
|
||||||
|
for (int i = 0; i < width; i++) {
|
||||||
|
table->column_width[i] = 5;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < height; i++) {
|
||||||
|
table->row_height[i] = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawGUI(int currentSelection) {
|
||||||
|
system("cls"); // 清除控制台屏幕
|
||||||
|
|
||||||
|
printf("======== GUI ========\n");
|
||||||
|
printf("| |\n");
|
||||||
|
printf("| [ ] [ ] |\n");
|
||||||
|
printf("| |\n");
|
||||||
|
printf("=====================\n");
|
||||||
|
|
||||||
|
if (currentSelection == 0) {
|
||||||
|
printf(" ^ \n"); // 显示指向第一个方块被选中
|
||||||
|
} else {
|
||||||
|
printf(" \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentSelection == 1) {
|
||||||
|
printf(" ^ \n"); // 显示指向第二个方块被选中
|
||||||
|
} else {
|
||||||
|
printf(" \n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int currentSelection = 0;
|
||||||
|
int keyPressed;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
drawGUI(currentSelection);
|
||||||
|
|
||||||
|
keyPressed = getch(); // 获取键盘输入
|
||||||
|
|
||||||
|
if (keyPressed == 224) { // 特殊键
|
||||||
|
keyPressed = getch(); // 获取特殊键码
|
||||||
|
|
||||||
|
if (keyPressed == 75) { // ←键
|
||||||
|
currentSelection = (currentSelection - 1) % 2; // 向左选择方块
|
||||||
|
} else if (keyPressed == 77) { // →键
|
||||||
|
currentSelection = (currentSelection + 1) % 2; // 向右选择方块
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int ans, a[10005];
|
||||||
|
int n;
|
||||||
|
int cx[100], zx[100], col[100];
|
||||||
|
|
||||||
|
void dfs(int x) {
|
||||||
|
if (x > n) {
|
||||||
|
ans++;
|
||||||
|
if (ans <= 3) {
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
printf("%d ", a[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
int l = x + i, r = x - i + 15;
|
||||||
|
if (cx[r] == 0 && zx[l] == 0 && col[i] == 0) {
|
||||||
|
a[x] = i;
|
||||||
|
cx[r] = 1;
|
||||||
|
zx[l] = 1;
|
||||||
|
col[i] = 1;
|
||||||
|
dfs(x + 1);
|
||||||
|
cx[r] = 0;
|
||||||
|
zx[l] = 0;
|
||||||
|
col[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
scanf("%d", &n);
|
||||||
|
dfs(1);
|
||||||
|
printf("%d", ans);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ref: P1219 [USACO1.5] 八皇后 Checker Challenge
|
||||||
|
// https://www.luogu.com.cn/record/40132197
|
|
@ -0,0 +1,34 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int rs[105],n,m,xcz;
|
||||||
|
|
||||||
|
int zj(int a){
|
||||||
|
a++;
|
||||||
|
if(a>n) a-=n;
|
||||||
|
while(rs[a]==0&&xcz>0){
|
||||||
|
a++;
|
||||||
|
if(a>n) a-=n;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
//freopen("title.txt","r",stdin);
|
||||||
|
scanf("%d%d",&n,&m);
|
||||||
|
xcz=n;
|
||||||
|
for(int i=1;i<=n;i++) rs[i]=1;
|
||||||
|
for(int i=m;xcz>0;){
|
||||||
|
if(rs[i]==1){
|
||||||
|
rs[i]=0;
|
||||||
|
xcz--;
|
||||||
|
printf("%d ",i);
|
||||||
|
}
|
||||||
|
int ls=m;
|
||||||
|
while(ls--) i=zj(i);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尚未修改到课程版本
|
||||||
|
// Ref: P1996 约瑟夫问题
|
Loading…
Reference in New Issue