#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str = new char[100];
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//释放内存
delete str;
str=NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str = new char[100];
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//释放内存
delete str;
str=NULL;
return 0;
}
int getMax(int a, int b)
{ return a>b?a:b;}
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;
}本地GCC是通过的啊怎么搞的?
{ return a>b?a:b;}
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;
}本地GCC是通过的啊怎么搞的?