程序阅读:运行以下程序的输出结果是______ ,______ 。(6分) #include "stdio.h"void main() { struct SHAPE { struct { int w,h; } in; int len , area; } e; e.in.w=1; e. in.h=2*e.in.w; e.len=2*( e.in.w + e.in.h2); e.area= e.in.w * e.in.h; printf("%d,%d",e.len, e.area); }
举一反三
- 若H = (W, F)是G = (V, E)的子图且W = V, 则称H = (W, F)是G = (V, E)的____。
- 设G = (V, E)和H = (W, F)是图, 若W是V的子集且F是E子集, 则称H = (W, F)是G = (V, E)的____。
- 【填空题】用拷贝构造函数进行对象构造。 #include<iostream> using namespace std; class Box { public: Box(int h,int w,int len); //构造函数声明 ( 1 ) //拷贝构造函数声明 int volume(); //求立方体体积函数 private: int height; int width; int length; }; Box::Box(int h,int w,int len) { height=h; width=w; length=len; } Box::Box(Box &a) { height=a.height+5; width=a.width+5; length=a.length+5; } int Box::volume() { return(height*width*length); } void main() { Box box1(5,5,5); cout<<"The volume of box
- 下列程序的输出结果为 class Box{ int length,width,height; public void setInfo(int l,int w,int h){ length = l; width = w; height = h; } public int volumn(){ return length*width*height; } public int area(){ return (length*width + length*height + width*height) * 2; } public String toString(){ return "Length:" + length + " width:" + width + " height:" + height + " volumn: " + volumn() + " area:" + area(); }} public class BoxTest { public static void main(String[] args) { Box b = new Box(); b.setInfo(5,2,4); System.out.println(b.toString()); }}
- 以下程序的输出结果是( )。 struct HAR { int x, y; struct HAR *p;} h[2]; main(){ h[0].x=1; h[0].y=2; h[1].x=3; h[1].y=4; h[0].p=&h[1]; h[1].p=h; printf("%d %d\n",(h[0].p)->x,(h[1].p)->y); }