Dinner——水php
#include<iostream> using namespace std; int lxh_strComp(char *str1, char *str2){ unsigned i; int result; for(i=0; str1[i]!=0 || str2[i]!=0; i++){ result = str1[i] - str2[i]; if(result != 0) break; } return result; } int main(){ char *arrStr[4] = {"bowl", "knife", "fork", "chopsticks"}; unsigned n, i; bool flag; char str[11]; while(cin>>n){ flag = false; for(i=0; i<n; i++){ cin>>str; str[10] = '\0'; if(lxh_strComp(str, arrStr[0])==0 || lxh_strComp(str, arrStr[1])==0 || lxh_strComp(str, arrStr[2])==0 || lxh_strComp(str, arrStr[3])==0){ if(flag) cout<<' '; cout<<str; flag = true; } } cout<<endl; } return 0; }