cout << ((s.find('!')!=string::npos) ? "YES" : "NO") << endl;
等於
bool t = 0;
for(int i=0; i<s.length(); i++){
if(s[i]=='!'){
t = 1;
break;
}
}
if(t == 1){
cout << "YES" << endl
}else{
cout << "NO" << endl;
}