c++学习(三)

//介绍了内联函数、引用、以及带有参数值的函数的使用例子
/*
#include"pch.h" #include<iostream> using namespace std; #define MAXSIZE 100 #define ElemType int //typedef int ElemType; typedef struct { ElemType *elem; int length; }SqList; Status InitList(SqList ) int main() { return 0; }*/ /*#include"pch.h" #include<iostream> using namespace std; void swap(int &a, int &b) { int t = a; a = b; b = t; } int main() { int x; int y; cout << "please input your number that you want to swap:" << endl; cin >> x >> y; cout << "x=" << x << "y=" << y << endl; swap(x, y); cout << "x=" << x << "y=" << y; return 0; }*/ /*#include"pch.h" #include<iostream> using namespace std; const double PI = 3.14159265358979; inline double calArea(double radius) { return PI * radius*radius; } int main() { double r = 3.0; double area = calArea(r); cout << area << endl; return 0; }*/ #include"pch.h" #include<iomanip> #include<iostream> using namespace std; int getVolume(int length, int width = 2, int height = 3); int main() { int x, y, z; cout << "please input x,y,z" << endl; cin >> x >> y >> z; cout << "some body is:" << endl; cout << getVolume(x, y, z) << endl; cout << "some body data is:" << endl; cout << getVolume(x, y) << endl; cout << "some body data is:" << endl; cout << getVolume(x) << endl; return 0; } int getVolume(int length, int width, int height) { cout << setw(5) << length << setw(5) << width << setw(5) << height << '\t'; return length * width*height; }

 

posted @ 2018-12-18 16:00  Maggieisxin  阅读(171)  评论(0)    收藏  举报