int getMax(int a,int b)
{if(a>b) return a;
else return b;}
int getMax(int a,int &b)
{int A=a;
int maxNum=b[0];
for(int i=1; i<A;i++)
{if(b[i]>maxNum) maxNum=b[i];}
return maxNum;}
int main(void)
{int numArr[3] = {3, 8, 6};
cout << getMax(3, 6) << endl;
cout << getMax(3,numArr[])<< endl;
return 0;}
{if(a>b) return a;
else return b;}
int getMax(int a,int &b)
{int A=a;
int maxNum=b[0];
for(int i=1; i<A;i++)
{if(b[i]>maxNum) maxNum=b[i];}
return maxNum;}
int main(void)
{int numArr[3] = {3, 8, 6};
cout << getMax(3, 6) << endl;
cout << getMax(3,numArr[])<< endl;
return 0;}
换了形式 C中是
in *p = (int *)malloc(sizeof(int));
C++
int *p = new int;
C:
int *arr = (int*)calloc(5,sizeof(int));
c++;
int *p = new int[5];
in *p = (int *)malloc(sizeof(int));
C++
int *p = new int;
C:
int *arr = (int*)calloc(5,sizeof(int));
c++;
int *p = new int[5];
2016-06-27
int getMax(int arr[],int count)
{
int maxNum = arr[0];
for(int i = 1; i < count; i++)
{if(arr[i]>maxNum)
{maxNum=arr[i];
}
}
return maxNum;
}
int main(void)
{int numArr[3] = {3, 8, 6};
cout << getMax(numArr[0], numArr[2]) << endl;
cout << getMax(numArr,3)<< endl;
return 0;
}
{
int maxNum = arr[0];
for(int i = 1; i < count; i++)
{if(arr[i]>maxNum)
{maxNum=arr[i];
}
}
return maxNum;
}
int main(void)
{int numArr[3] = {3, 8, 6};
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 <*p; 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 <*p; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}