C++程序设计编程实例大全.docx
- 文档编号:6121607
- 上传时间:2023-01-04
- 格式:DOCX
- 页数:160
- 大小:39.95KB
C++程序设计编程实例大全.docx
《C++程序设计编程实例大全.docx》由会员分享,可在线阅读,更多相关《C++程序设计编程实例大全.docx(160页珍藏版)》请在冰豆网上搜索。
C++程序设计编程实例大全
C++程序编程实例大全
#include
intmain()
{
std:
:
cout<<"helloworld!
";
}
#include"iostream"
usingnamespacestd;
voidmain()
{
int*p;
p=newint;
*p=5;
/*p=newint(5);*/
cout<<*p;
deletep;
}
#include"iostream"
usingnamespacestd;
voidmain()
{charname[10];
cout<<"pleaseinputyourname:
";
cin>>name;
cout<<"thenameis"< } #include"iostream" usingnamespacestd; voidmain() {charname[10]; intage; cout<<"pleaseinputyourname: "; cin>>name; cout<<"howoldareyou: "; cin>>age; cout<<"thenameis"< cout<<"theageis"< } #include"iostream" usingnamespacestd; voidmain() { structstudent { intno; floatmath; }; intn; cin>>n; studentwang; wang.no=n; cin>>wang.math; cout< } #include"iostream" usingnamespacestd; voidmain() { int*p; intn; cout<<"pleaseinputthelengthofthearray: "; cin>>n; if((p=newint[n])==0) { cout<<"can'tallocatemorememory,terminating"< exit (1); } for(inti=0;i p[i]=i*2; cout<<"Nowoutputthearray: "< for(i=0;i cout< delete[]p; } #include"iostream" usingnamespacestd; voidmain() { int*p; intn; cout<<"pleaseinputthelengthofthearray: "; cin>>n; if((p=newint[n])==0) { cout<<"can'tallocatemorememory,terminating"< exit (1); } for(inti=0;i p[i]=i*i+1; cout<<"Nowoutputthearray: "< for(i=0;i cout< cout< delete[]p; } /*Note: YourchoiceisCIDE*/ #include usingnamespacestd; floata=2.4; voidmain() { inta=8; cout< cout<<: : a< } /*Note: YourchoiceisCIDE*/ #include voidmain() { intnum=50; int&ref=num; ref+=10; cout<<"num="< cout<<"ref="< num+=40; cout<<"num="< cout<<"ref"< } /*Note: YourchoiceisCIDE*/ #include voidmain() { intnum; int&ref=num; num=5;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C+ 程序设计 编程 实例 大全