JackYue2011 • 1年前
#include <bits/stdc++.h>
using namespace std;
string str1,str2;
int b,e,tmp;
int main()
{
cin >> str1 >> str2;
b = str1.find("(");
e = str2.find(")");
str1 = str1.substr(b + 1,e - b - 1);
tmp = str2.find("...");
str2.erase(tmp,3);
cout << str1 << "," << str2;
return 0;
}
这哪儿错了呀!!!
评论:
没有错
提交时间:2022-10-19 20:22:48
运行 ID: 61582
#include <iostream>
#include <string>
using namespace std;
char arr[10] = {'0','1','2','3','4','5','6','7','8','9'};
char letter[2] = {'(',')'};
int main(){
string str1,str2;
cin >> str1 >> str2;
int begin = str1.find("(");
int end = str1.find(")");
string ans = str1.substr(begin+1,end-begin-1);
int t = str2.find(".");
str2.erase(t,3);
ans += "," ;
cout << ans << str2 << endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
string str1,str2;
int b,e,tmp;
int main()
{
cin >> str1 >> str2;
b = str1.find("(");
e = str2.find(")"); //你截取了str2
str1 = str1.substr(b + 1,e - b - 1);
tmp = str2.find("..."); //你不应该找三个点,而是找最前面的那一个
str2.erase(tmp,3);
cout << str1 << "," << str2;
return 0;
}
这样就行了。
#include <bits/stdc++.h>
using namespace std;
string str1,str2;
int b,e,tmp;
int main()
{
cin >> str1 >> str2;
b = str1.find("(");
e = str1.find(")");
str1 = str1.substr(b + 1,e - b - 1);
tmp = str2.find(".");
str2.erase(tmp,3);
cout << str1 << "," << str2;
return 0;
}