1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 6 int main() 7 { 8 string str("some thing"); 9 for(auto &c:str) 10 if(!isspace(c)) 11 c=‘X‘; 12 13 cout<<str<<endl; 14 return 0; 15 }
1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 6 int main() 7 { 8 string str("some thing"); 9 for(decltype(str.size()) i = 0 ; i<str.size() ; ++i) 10 if(!isspace(str[i]))str[i]=‘X‘; 11 12 cout<<str<<endl; 13 return 0; 14 }
时间: 2024-11-04 04:37:32