1. A.字符串连接
2. 首字母大写
4. 字符串的查找删除
5. 单词替换
6. 字符串去特定字符
7. 数组逆置
8. 比较字符串
9. 编排字符串
10. 【字符串】回文串
A
#include<bits/stdc++.h>
using namespace std;
int main(){
string s1,s2;
while(cin>>s1>>s2){
cout<<s1<<s2<<endl;
}
return 0;
}
/**************************************************************
Problem: 1785
User: 311809000531
Language: C++
Result: 正确
Time:3 ms
Memory:2180 kb
****************************************************************/
B
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
while(getline(cin,s)){
int len = s.size();
if(s[0]>='a' && s[0]<='z') s[0]-=32;
for(int i=1;i<len;i++){
if(s[i-1]==' ' || s[i-1]=='\t' || s[i-1]=='\r' ||s[i-1]=='\n'){
if(s[i] >='a' && s[i]<='z') s[i] -= 32;
}
}
for(int i=0;i<len;i++){
cout<<s[i];
}
cout<<endl;
}
return 0;
}
/**************************************************************
Problem: 1805
User: 311809000531
Language: C++
Result: 正确
Time:3 ms
Memory:2180 kb
****************************************************************/
C
#include<bits/stdc++.h>
using namespace std;
int main(){
string s1;
cin>>s1;
for(int i=0;i<s1.size();i++){
s1[i] = tolower(s1[i]);
}
getchar();
int pos;
string s2,s3;
string str;
while(getline(cin,str)){
// getchar();
s3 = s2 = str;
int len = s2.size();
for(int i=0;i<len;i++){//对s2处理,删去对应的s3的位置,最后输出s3,因为输出非匹配串的时候大小写不变
s2[i] = tolower(s2[i]);
}
//删除短字符串
pos = s2.find(s1,0);
while(pos!=string::npos){
s2.erase(pos,s1.size());
s3.erase(pos,s1.size());
pos = s2.find(s1,pos);//更新新的位置
}
//删除长字符串
pos = s3.find(' ',0);
while(pos!=string::npos) {
s3.erase(pos,1);
pos = s3.find(' ',pos);
}
cout<<s3<<endl;
}
return 0;
}
/**************************************************************
Problem: 1808
User: 311809000531
Language: C++
Result: 正确
Time:5 ms
Memory:2180 kb
****************************************************************/
D
#include<stdio.h>
#include<string.h>
int main()
{
char arr[101][101],a[101],b[101];
int i,j;
while(scanf("%s",arr[0])!=EOF)
{
i=1;
while(getchar()!='\n')
scanf("%s",arr[i++]);
scanf("%s",a);
scanf("%s",b);
//找出单词并替换
for(j=0; j<i-1; j++)
{
if(strcmp(a,arr[j])==0)//说明相等
{
printf("%s ",b);
}
else
{
printf("%s ",arr[j]);
}
}
if(strcmp(a,arr[j])==0)//说明相等
{
printf("%s ",b);
}
else
{
printf("%s ",arr[j]);
}
printf("\n");
}
return 0;
}
/**************************************************************
Problem: 1962
User: 311809000531
Language: C++
Result: 正确
Time:3 ms
Memory:1192 kb
****************************************************************/
E
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
char c;
while(getline(cin,s)){
scanf("%c",&c);
for(int i=0;i<s.size();i++){
if(s[i]==c){
continue;
}
else{
cout<<s[i];
}
}
cout<<endl;
getchar();
}
return 0;
}
/**************************************************************
Problem: 1963
User: 311809000531
Language: C++
Result: 正确
Time:3 ms
Memory:2180 kb
****************************************************************/
F
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
while(getline(cin,s)){
reverse(s.begin(),s.end());
cout<<s<<endl;
}
return 0;
}
/**************************************************************
Problem: 1967
User: 311809000531
Language: C++
Result: 正确
Time:4 ms
Memory:2180 kb
****************************************************************/
G
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
string a,b;
cin>>a>>b;
if(a.size() > b.size()) cout<<a<<" is longer than "<<b<<endl;
else if(a.size() == b.size()) cout<<a<<" is equal long to "<<b<<endl;
else cout<<a<<" is shorter than "<<b<<endl;
}
return 0;
}
/**************************************************************
Problem: 2025
User: 311809000531
Language: C++
Result: 正确
Time:2 ms
Memory:2180 kb
****************************************************************/
H
#include<bits/stdc++.h>
using namespace std;
vector<string> ve;
int main(){
int t;
cin>>t;
for(int i=1;i<=t;i++){
string s;
cin>>s;
ve.push_back(s);
for(int j=1;j<=ve.size()&&j<=4;j++){
if(i==j) cout<<j<<"="<<ve[ve.size()-j];
else cout<<j<<"="<<ve[ve.size()-j]<<" ";
}
cout<<endl;
}
return 0;
}
/**************************************************************
Problem: 2064
User: 311809000531
Language: C++
Result: 正确
Time:5 ms
Memory:2180 kb
****************************************************************/
I
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
string ss = s;
reverse(s.begin(),s.end());
if(s == ss) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
/**************************************************************
Problem: 5901
User: 311809000531
Language: C++
Result: 正确
Time:3 ms
Memory:2180 kb
****************************************************************/