void display(string s1,string s2=" ",string s3=" ");//申明函数display,并且s2和s3默认为空。void display(string s1,string s2,string s3){ if (s2==" "&&s3==" ") cout< else if(s3==" "&&s2!=" ") cout< else cout<}然后主函数多次调用,只要把参数代表的字符串看清楚了,你就能很容易得到答案了