实验6函数与预处理1_参考解析.docVIP

  • 2
  • 0
  • 约5.36千字
  • 约 10页
  • 2017-02-07 发布于湖北
  • 举报
实验’T’的功能,要求使用内联函数 #includeiostream #includecstring using namespace std; inline char fun(char ch) //内联函数fun首部 { if (ch == T) return 0; //内联函数fun函数体,语句数量不限 } int main() { char c; cout please input a string: endl; while ((c = getchar()) != \n) { if (fun(c)) //对于if来说除了0之外都是1 cout fun(c); } cout \n; return 0; } 自测题二 编写重载函数Max可分别求取两个整数,三个整数,两个双精度数,三个双精度数的最大值。 #include iostream using namespace std; int max(int a, int b) {/*功能:求取两个整数的最大值,语句数量不限 */ cout int max(int a, int b):; return a b ? a : b; } int max(int a, int b, int c) {/*求取三个整数的最大值,语句数量不限 */ cout

文档评论(0)

1亿VIP精品文档

相关文档