课评: 转出学生归档(王子墨/张立坤/黄俊博)+ 周四班级总结 + 新生章梓皓档案 + C++示例代码

This commit is contained in:
chengzi
2026-09-29 22:43:54 +08:00
parent 6f57dfe67e
commit 73cce4c4f5
116 changed files with 6817 additions and 248 deletions

View File

@@ -0,0 +1,38 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
string s, a; // s
int dc = 0; // 当前是第几个单词
int zm = 0; // 当前是第几个字母
int main(){
getline(cin, s);
cin >> a;
string curr = "";
for(char c : s){
if(c == ' ' || c == '.'){
// 中断
// 出现一个单词
// if(curr.size() == 0){
// continue;
// }
dc++; // 单词数加一
cout << curr << " ";
if(curr == a){
cout << dc;
return 0;
}
curr = "";
} else {
curr += c;
zm++; // 字母数加一
}
}
cout << zm;
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,21 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
string str;
int main(){
// 两种读入
// cin >> str; // 局限:遇到空格就结束
getline(cin, str);
// cout << str;
// int len = str.size(); // 字符串.size(); 可以获得字符串的长度
for(char c : str){
cout << c << " ";
}
return 0;
}

Binary file not shown.

View File

@@ -6,18 +6,25 @@ int n;
int arr[100100];
int main(){
char c;
cin >> c;
string str = "abacad";
// // 截取子串 字符串.substr(pos, num) pos 想从什么位置开始截取 num截取多长
// string sub1 = str.substr(1, 2);
// // 截取子串 函数重载
// string sub = str.substr(1);
// 判断c是大写还是小写
if(c >= 'a' && c <= 'z'){
// 小写
c = c - 'a' + 'A';
} else {
c = c - 'A' + 'a';
// 查找
// 字符串.find('a');
int idx = -1;
while(1){
if(idx >= str.size()) break;
idx = str.find('a', idx + 1);
cout << idx << " ";
}
cout << c;
// if(str.find('h') == string::npos){
// cout << "没有出现过";
// }
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,29 @@
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
int arr[100100];
int main(){
// 替换
string s = "abcdef";
// // 字符串.replace(pos, len, newstr);
// cout << s.replace(1, 2, "ab cd");
//
//// s.size() // 如果是空 false
//// s.empty() // 判断s是不是空的 true
//
// // 比较大小
// string s1 = "123", s2 = "A";
//
// cout << (s1 < s2); // 0
//
s.erase(1, 2);
cout << s;
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,31 @@
#include<bits/stdc++.h>
using namespace std;
int k,x, zm;
string s,fi,w="";
int main() {
getline(cin,s);
cin >> fi;
int m=s.size();
for(int i=0; i<m; i++) {
s[i];
if(isphla(s[i])){
}
if(s[i]==' '||s[i]=='.') {
// 判断w是不是空
if(w != "") {
k++;
if(w==fi) {
cout <<k;
return 0;
}
w="";
}
} else w+=s[i];
}
cout << zm;
return 0;
}

Binary file not shown.