合集-基础语法题解(字符串)

摘要:#include<bits/stdc++.h> #define ll long long using namespace std; int main() { string a; while(cin>>a){ //cin输入会有返回 char c = a[0]; //取出第一个字符 if(c>'Z') 阅读全文
posted @ 2024-10-22 19:54 行胜于言Ibl 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main(){ string a,b; //字符串可能空格,所以使用扫描一整行的方式 getline(cin,a); getline(cin,b); //把a字符串变成长的 if(a.size()<b. 阅读全文
posted @ 2024-10-31 14:59 行胜于言Ibl 阅读(38) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; char maxn[51],t[51]; //先输入第一个单词 cin>>maxn; n--; //数量-1 while(n--){ cin>>t; / 阅读全文
posted @ 2024-10-31 15:02 行胜于言Ibl 阅读(35) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define ll long long using namespace std; int main(){ //长度不相等:1234567 5267 长度长的数字大 string a,b; cin>>a>>b; if(a.size()!=b.size( 阅读全文
posted @ 2024-10-31 15:05 行胜于言Ibl 阅读(23) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> #define ll long long using namespace std; int main() { string s; getline(cin,s); cout<<s.size()<<endl; int cnt=0; for(int i=0 阅读全文
posted @ 2024-10-31 15:06 行胜于言Ibl 阅读(44) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define ll long long using namespace std; /* double b = 3.1415926535 C++的保留小数 fixed << setprecision(小数位数)<<要保留小数的变量或表达式 fixed 阅读全文
posted @ 2024-10-31 15:07 行胜于言Ibl 阅读(50) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> #define ll long long using namespace std; //利用桶标记的概念 int a[26]; // a[0]代表字母a出现的次数,a[1]代表b...以此类推 int main() { string s; cin>> 阅读全文
posted @ 2024-10-31 15:09 行胜于言Ibl 阅读(32) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin,s); cout<<s; char a; a=s[0]; //把第一个字符先存起来 s[0]=s[s.length()-1]; //把第一 阅读全文
posted @ 2024-10-31 15:12 行胜于言Ibl 阅读(28) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int n; cin>>n; int maxn=-1;//记录最大的分数 string ans; //记录分数最高学生姓名 while(n- 阅读全文
posted @ 2024-10-31 15:13 行胜于言Ibl 阅读(23) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { string s; getline(cin,s); for(int i=0;i<s.size();i++){ //检查到“,”就结束遍历 if(int(s[i])==','){ bre 阅读全文
posted @ 2024-10-31 15:14 行胜于言Ibl 阅读(30) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> #define ll long long using namespace std; int main() { string s1,s2; getline(cin,s1); getline(cin,s2); //准备两个字符串,把原本字符串空格去掉后存 阅读全文
posted @ 2024-10-31 15:15 行胜于言Ibl 阅读(18) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> using namespace std; int main() { string s; cin>>s; cout<<s; //先输出原字符串 s[0]-=32; //首字母变大写 cout<<s; //再输出新的单词 return 0; } 阅读全文
posted @ 2024-10-31 15:17 行胜于言Ibl 阅读(15) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> #define ll long long using namespace std; int main() { string s; cin>>s; //利用双指针的方式,L指向第一个字符,R指向最后一个字符 //f标记,0代表不是回文,1代表室回文 i 阅读全文
posted @ 2024-10-31 15:19 行胜于言Ibl 阅读(21) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main(){ string a,b; //字符串可能空格,所以使用扫描一整行的方式 getline(cin,a); getline(cin,b); bool f = 0;//1代表是子串,0代表不是 阅读全文
posted @ 2024-10-31 15:21 行胜于言Ibl 阅读(31) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> using namespace std; int main(){ string a,b; getline(cin,a); getline(cin,b); //将字符串中所有的字母均转换为小写字母 for(int i=0;i<a.size();i++) 阅读全文
posted @ 2024-10-31 15:27 行胜于言Ibl 阅读(27) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main() { string a,b; cin>>a>>b; //利用字符串的比较函数 if(a.compare(b)<=0){ cout<<a<<b; }else{ cout<<b<<a; } re 阅读全文
posted @ 2024-10-31 15:37 行胜于言Ibl 阅读(31) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define ll long long using namespace std; int main() { string s; cin>>s; cout<<s<<endl;//先输出原字符串 for(int i=0; i<s.size(); i++) 阅读全文
posted @ 2024-10-31 15:39 行胜于言Ibl 阅读(34) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; int main(){ string a,b; //字符串可能空格,所以使用扫描一整行的方式 getline(cin,a); getline(cin,b); int cnt=0; //统计结果 for(int 阅读全文
posted @ 2024-10-31 15:41 行胜于言Ibl 阅读(29) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> #define ll long long using namespace std; int main() { // 读取输入的字符串 string s; cin >> s; // 初始化有效性标志为1(有效) int f = 1; // 定义年、月、 阅读全文
posted @ 2024-10-31 15:45 行胜于言Ibl 阅读(34) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示