补全9月11日至13日课评:为13名学生创建请假文档,为5个班级创建总结文档

This commit is contained in:
chengzi
2026-09-13 19:34:34 +08:00
parent 167d832353
commit 21001eccf5
1322 changed files with 37510 additions and 4136 deletions

View File

@@ -0,0 +1,70 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, m, x, y;
int cntt[1010][1010];
char arr[1010][1010];
int tot = 0;
int sz[1000010];
int fx[] = {0, 0, 1, 0, -1};
int fy[] = {0, 1, 0, -1, 0};
int q[1000010][3];
void bfs(int x, int y){
int cnt = 1;
tot++;
q[1][1] = x;
q[1][2] = y;
cntt[x][y] = tot;
int head = 1, tail = 1;
while(head <= tail){
int cx = q[head][1];
int cy = q[head][2];
int tx, ty;
for(int i = 1; i <= 4; i++){
tx = cx + fx[i];
ty = cy + fy[i];
if(tx >= 1 && tx <= n && ty >= 1 && ty <= n && cntt[tx][ty] == 0
&& (arr[cx][cy] != arr[tx][ty])){
tail++;
q[tail][1] = tx;
q[tail][2] = ty;
cntt[tx][ty] = tot;
// cout << "ÎÒ¿ÉÒÔÀ´";
cnt++;
}
}
head++;
}
sz[tot] = cnt;
}
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
cin >> arr[i][j];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(cntt[i][j] == 0) bfs(i, j);
}
}
for(int i = 1; i <= m; i++){
cin >> x >> y;
cout << sz[cntt[x][y]] << endl;
}
return 0;
}

Binary file not shown.

16
C++代码/学习/1.cpp Normal file
View File

@@ -0,0 +1,16 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
string n;
int main(){
cin >> n;
for(int i = 0; i < n.size(); i++){
if(n[i] == '4') cout << '8';
else cout << n[i];
}
return 0;
}

BIN
C++代码/学习/1.exe Normal file

Binary file not shown.

View File

@@ -0,0 +1,55 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, a, b;
int cnt = 0;
int arr[100100];
int fx[] = {0, 1, -1};
int q[100000][2]; // ϱê0±íʾ´ÎÊý
void bfs(int k){
int head = 1, tail = 1;
q[head][0] = 0;
q[head][1] = k;
while(head <= tail){
int curr = q[head][1]; //µ±Ç°Â¥²ã
int tx;
for(int i = 1; i <= 2; i++){
tx = curr + fx[i] * arr[curr];
if(tx >= 1 && tx <= n){
tail++;
q[tail][0] = q[head][0] + 1;
q[tail][1] = tx;
if(tx == b) {
cout << q[tail][0];
exit(0);
}
}
}
head++;
}
}
int main(){
cin >> n >> a >> b;
if(a == b){
cout << 0;
return 0;
}
for(int i = 1; i <= n; i++){
cin >> arr[i];
}
bfs(a);
cout << -1;
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,66 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, m;
int arr[1010][1010];
int bol[1010][1010];
int s1, s2, e1, e2;
int fx[] = {0, 0, 1, 0, -1};
int fy[] = {0, 1, 0, -1, 0};
struct Node {
int x;
int y;
int cnt;
};
queue<Node> q; //
void bfs(int x, int y) {
Node nd;
nd.x = x;
nd.y = y;
nd.cnt = 0;
bol[x][y] = 1;
q.push(nd);
while(q.size()) {
Node head = q.front();
int cx = head.x;
int cy = head.y;
int cnt = head.cnt;
int tx, ty;
for(int i = 1; i <= 4; i++) {
tx = cx + fx[i];
ty = cy + fy[i];
while(tx >= 1 && tx <= n && ty >= 1 && ty <= m && arr[tx][ty] == 0) {
if(bol[tx][ty] == 0){
q.push({tx, ty, cnt + 1});
bol[tx][ty] = 1;
}
if(tx == e1 && ty == e2){
cout << cnt;
return ;
}
tx += fx[i];
ty += fy[i];
}
}
q.pop();
}
}
int main() {
cin >> n >> m;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
cin >> arr[i][j];
}
}
cin >> s1 >> s2;
cin >> e1 >> e2;
bfs(s1, s2);
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,23 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
int arr[100100];
int main(){
char c;
cin >> c;
// 判断c是大写还是小写
if(c >= 'a' && c <= 'z'){
// 小写
c = c - 'a' + 'A';
} else {
c = c - 'A' + 'a';
}
cout << c;
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,32 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
int arr[100100];
int main(){
// 循环拆位
int num, sum = 0;
cin >> num;
int t = num;
while(t > 0){
// 第一步 获取最一位
int g = t % 10; // %10 获得最后一位
// 第二步 我们要进行的操作
sum = sum * 10 + g;
// 第三步 去掉最后一位
t /= 10;
}
if(sum == num){
cout << "是回文串";
} else {
cout << "不是回文串";
}
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,33 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
int arr[100100];
// 判断一个数是不是质数
int main(){
int num;
cin >> num;
bool ok = true; // 一开始我认为这个数是质数
// 质数(素数):除了1和它本身
for(int i = 2; i <= sqrt(num); i++){
// 让i 作为除数
if(num % i == 0){
// i把num整除了
ok = false;
break;
}
}
if(ok){
cout << "是质数";
} else {
cout << "不是质数";
}
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,34 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
// 拆位:短除法 1234 4321 %10
// 1234 1234 /1000 %1000 /100
int n, cnt = 1;
cin >> n;
// 先获得这个数的位数
int t = n;
while(t /= 10){
cnt *= 10;
}
cout << cnt;
// while(cnt){
// int f = n / cnt; // 得到第一位
//
// // 如果这个数是4 就改成8
// if(f == 4){
// f = 8;
// }
// cout << f;
//
// // 获得后面的几位数
// n %= cnt;
// cnt /= 10;
// }
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,25 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, m;
int arr[100100];
int dp[100100];
int x, y;
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> arr[i];
dp[i] = dp[i - 1] + arr[i];
}
for(int i = 1; i <= m; i++){
cin >> x >> y;
cout << dp[y] - dp[x - 1] << endl;
}
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,72 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, m, z; // z表示当前走了多少个节点
int arr[160][160];
int s1, s2, e1, e2;
int fx[] = {0, 0, 1, 0, -1};
int fy[] = {0, 1, 0, -1, 0};
int q[40000][3]; // 下标0表示前上一个点
void print(int k){
if(k == 0) return ;
print(q[k][0]); // 先走回到最前面的位置
cout << "(" << q[k][1] << "," << q[k][2] << ")";
if(k != z) cout << "->";
}
void bfs(int x, int y){
q[1][0] = 0;
q[1][1] = x;
q[1][2] = y;
arr[x][y] = 1;
int head = 1, tail = 1;
while(head <= tail){
int cx = q[head][1];
int cy = q[head][2];
int tx, ty;
for(int i = 1; i <= 4; i++){
tx = cx + fx[i];
ty = cy + fy[i];
if(tx >= 1 && tx <= n && ty >= 1 && ty <= m && arr[tx][ty] == 0){
tail++;
q[tail][0] = head;
q[tail][1] = tx;
q[tail][2] = ty;
if(tx == e1 && ty == e2){
z = tail;
print(tail);
exit(0);
}
arr[tx][ty] = 1;
}
}
head++;
}
}
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> arr[i][j];
}
}
cin >> s1 >> s2 >> e1 >> e2;
bfs(s1, s2);
cout << "no way";
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,55 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, m;
const int MAX = 50;
char mapp[MAX][MAX];
int step[MAX][MAX];
struct Node{
int x, y;
};
queue<Node> q;
int fx[] = {0, 0, 1, 0, -1};
int fy[] = {0, 1, 0, -1, 0};
void bfs(int x, int y){
Node dian;
dian.x = x;
dian.y = y;
step[x][y] = 1;
q.push(dian);
while(q.size()){
int cx = q.front().x;
int cy = q.front().y;
int tx, ty;
for(int i = 1; i <= 4; i++){
tx = cx + fx[i];
ty = cy + fy[i];
if(tx >= 1 && tx <= n && ty >= 1 && ty <= m && mapp[tx][ty] == '.' && step[tx][ty] == 0){
q.push({tx, ty});
step[tx][ty] = step[cx][cy] + 1;
if(tx == n && ty == m) return ;
}
}
q.pop();
}
}
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> mapp[i][j];
}
}
bfs(1, 1);
cout << step[n][m];
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, k, cnt = 0;
long long dp[70010];
int main(){
cin >> n >> k;
for(int i = 1; i <= n; i++){
dp[i] = dp[i-1] + i;
}
for(int i = k; i <= n; i++){
long long curr = dp[i] - dp[i-k];
// 判断这个数是不是某一个数的平方
if((int)sqrt(curr) * (int)sqrt(curr) == curr){
cnt++;
}
}
cout << cnt;
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#include <iostream>
using namespace std;
int main(){
int M;
cin >> M;
int l = 1, r = 1;
long long sum = 0;
while (l <= M/2){
if (sum < M){
sum += r;
r++;
}else if (sum > M){
sum -= l;
l++;
}else{
cout << l << " " << r-1 << endl;
sum -= l;
l++;
}
}
return 0;
}

Binary file not shown.