65,211
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <string>
#include <cctype>
using std::string;
using std::cin;
using std::cout;
using std::endl;
int main() {
string str, temp;
cin >> str;
string::size_type index, j;
for(index = 0, j = 0; index < str.size(); ++index) {
if(!ispunct(str[index])) {
temp[j] = str[index];
++j;
//cout << str[index] << " " << j << endl;
}
}
for(int i = 0; i<3; ++i) {
cout << temp[i] << endl;
}
cout << temp << "ok" << endl;
//str = temp;
//cout << str << endl;
return 0;
}
#include <iostream>
#include <string>
#include <cctype>
using std::string;
using std::cin;
using std::cout;
using std::endl;
int main()
{
string str, temp;
cin >> str;
string::const_iterator index=str.begin();
for(; index !=str.end(); ++index)
if(!ispunct(*index))
temp.push_back(*index);
for(int i = 0; i<3; ++i)
cout << temp[i] << endl;
cout << temp << "ok" << endl;
//str = temp;
//cout << str << endl;
return 0;
}