课评: 转出学生归档(王子墨/张立坤/黄俊博)+ 周四班级总结 + 新生章梓皓档案 + C++示例代码
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user