#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
int&y=x;
cout<<x<<y<<endl;
y = 88;
cout<<x<<y<<endl;
return 0;
}
using namespace std;
int main(void)
{
int x = 3;
int&y=x;
cout<<x<<y<<endl;
y = 88;
cout<<x<<y<<endl;
return 0;
}
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請100個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)
{
//在堆中申請100個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;
}
//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;
}
最贊回答 / 程序卓
system("pause")就是從程序里調(diào)用“pause”命令,這樣在程序運行完后會有一句“請按任意鍵繼續(xù)”的指示,只有按一下才會關(guān)閉窗口,如果沒有的話窗口就直接關(guān)閉了,很有可能看不見程序反饋的信息
2017-03-25
int getMax(int arr[],int count)
{ int a=arr[0];
for(int i = 1; i < count; i++)
{ if(a<arr[i])
元素比maxNum大,則獲取數(shù)組中的值
a=arr[i]; }
}
return a;
}
int main(void)
{
//定義int數(shù)組并初始化
int numArr[] = {3, 8, 6,10,55,44,88};
cout << getMax(numArr, 7) << endl;
system("pause");
return 0;
}
{ int a=arr[0];
for(int i = 1; i < count; i++)
{ if(a<arr[i])
元素比maxNum大,則獲取數(shù)組中的值
a=arr[i]; }
}
return a;
}
int main(void)
{
//定義int數(shù)組并初始化
int numArr[] = {3, 8, 6,10,55,44,88};
cout << getMax(numArr, 7) << endl;
system("pause");
return 0;
}