#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請(qǐng)100個(gè)char類型的內(nèi)存
char *str = new char[100];
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//釋放內(nèi)存
delete []str;
str=NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請(qǐng)100個(gè)char類型的內(nèi)存
char *str = new char[100];
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//釋放內(nèi)存
delete []str;
str=NULL;
return 0;
}
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請(qǐng)100個(gè)char類型的內(nèi)存
char *str = new char[100];
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(str, "Hello imooc");
//打印字符串
cout << str << endl;
//釋放內(nèi)存
delete []str;
str = NULL;
return 0;
}javascript:;
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請(qǐng)100個(gè)char類型的內(nèi)存
char *str = new char[100];
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(str, "Hello imooc");
//打印字符串
cout << str << endl;
//釋放內(nèi)存
delete []str;
str = NULL;
return 0;
}javascript:;
已通過
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請(qǐng)100個(gè)char類型的內(nèi)存
char *str = new char[100];
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(*str, "Hello imooc");
//打印字符串
cout<<*str<<endl;
//釋放內(nèi)存
delet []str;
str=NULL;
return 0;
}
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請(qǐng)100個(gè)char類型的內(nèi)存
char *str = new char[100];
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(*str, "Hello imooc");
//打印字符串
cout<<*str<<endl;
//釋放內(nèi)存
delet []str;
str=NULL;
return 0;
}
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(5, 6) << 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(5, 6) << endl;
cout << getMax(numArr,3)<< endl;
return 0;
最新回答 / 咕嚕嘟咚
我也不太清楚,應(yīng)該是因?yàn)樵谡{(diào)用函數(shù)時(shí)會(huì)自動(dòng)為里面的參數(shù)賦值(賦自己輸入的值)吧
2017-08-26
最新回答 / 慕粉1527144879
?"http://比較變量與下一個(gè)元素的大小"這行代碼下你arr寫出arrr,并且你這樣寫結(jié)果應(yīng)該是6,8才是啊,
2017-08-24
//const
#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;
}
#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;
}