改错题
第1题
#include ﹤iostream.h﹥
using namespace std;
void setzero(int &a)
{
a=0;
}
int main( )
{
int x1=10; setzero(&x1);
cout ﹤﹤x1﹤﹤ endl;
return 0;
}
第2题
改正后程序输出结果为2 5 8 11 14
#include ﹤iostream. h﹥
using namespace std;
void main( )
{
int i=1;
while(i﹤=15)
{
i++; if(i%3==2) continue;
else cout ﹤﹤1﹤﹤" ";
}
}
第3题
#include ﹤iostream. h﹥
using namespace std;
class Point
{
public: void init( ) {
}
static void output( ) {
}
};
void main( )
{
Point P;
Point:: init( );
P. output( );
}
第4题
#include ﹤iostream. h﹥
using namespace std;
class A
{
int x, y; public: void set(int a, int b)
{
x=a; y=b;
}
int getx( )
{
return x;
}
int gety( )
{
return y;
}
int sum( )
{
return x+y;
}
}; int main( )
{
A a; a. set(3, 4);
cout﹤﹤a.x﹤﹤a.y﹤﹤ a.sum( )﹤﹤ endl;
return 0;
}
第5题
申请一个长度为10的int型空间,之后释放该空间。
#include ﹤iostream. h﹥
using namespace std;
int main( )
{
int *p=new int[ 10];
delete p;
return 0;
}
本文导航
- 第1页: 首页
- 第2页: 填空题
- 第3页: 改错题
- 第4页: 完成程序题
- 第5页: 程序分析题
- 第6页: 程序设计题