int main(void)
{
//定义int数组并初始化
int numArr[3] = {3, 8, 6};
//自动调用int getMax(int a, int b)
cout << getMax(numArr, 3) << endl;
//自动调用返回数组中最大值的函数返回数组中的最大值
cout << maxNum << endl;
return 0;
}
{
//定义int数组并初始化
int numArr[3] = {3, 8, 6};
//自动调用int getMax(int a, int b)
cout << getMax(numArr, 3) << endl;
//自动调用返回数组中最大值的函数返回数组中的最大值
cout << maxNum << endl;
return 0;
}
int getMax(int *a, int *b)
{
return a > b ? a : b;
}
int main(void)
{
//定义int数组并初始化
int numArr[3] = {3, 8, 6};
//自动调用int getMax(int a, int b)
cout << getMax(numArr[0], numArr[2]) << endl;
//自动调用返回数组中最大值的函数返回数组中的最大值
cout << getMax(numArr[3])<< endl;
return 0;
}
{
return a > b ? a : b;
}
int main(void)
{
//定义int数组并初始化
int numArr[3] = {3, 8, 6};
//自动调用int getMax(int a, int b)
cout << getMax(numArr[0], numArr[2]) << endl;
//自动调用返回数组中最大值的函数返回数组中的最大值
cout << getMax(numArr[3])<< endl;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//定义常量count
const int count = 3;
const int *p = &count;
//打印count次字符串Hello C++
for(int i = 0; i < count; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}
using namespace std;
int main(void)
{
//定义常量count
const int count = 3;
const int *p = &count;
//打印count次字符串Hello C++
for(int i = 0; i < count; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y=x;
//打印x和y的值
cout<<x<<endl;
cout<<y<<endl;
//修改y的值
y = 6;
//再次打印x和y的值
cout<<x<<","<<y<<endl;
return 0;
}
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y=x;
//打印x和y的值
cout<<x<<endl;
cout<<y<<endl;
//修改y的值
y = 6;
//再次打印x和y的值
cout<<x<<","<<y<<endl;
return 0;
}