2023-11-22 20:54来源:m.sf1369.com作者:宇宇
帮你写一个吧
public AirCondition extends Device{
private int temperature;
private String dName;
private String address;
private double price;
public AirCondition(String dName, String address,double price,int temperature){
this.temperature=temperature;
this.address=address;
this.dName=dName;
this.price=price;
}
public void raiseTemp (int temp){
this.temperature=this.temperature+temp;
}
public void lowerTemp(int temp){
this.temperature=this.temperature-temp;
}
public String toString(){
return this.dName+ +this.address+ +this.double+ +this.temperature;
}
}
#include#include void sort(struct book b[]); void output(struct book b[]); struct book { char name[20]; int price; int num; int amount; }; int count=0; void main() { struct book b[10]; int j; for(int i=0;i<10;i++) { printf(请输入书的名字:); scanf(%s,&b[i].name); printf(请输入书的价格:); scanf(%d,&b[i].price); printf(请输入书的数量:); scanf(%d,&b[i].num); count++; printf(是否继续继续增加一本书(1:继续,0:结束)); scanf(%d,&j); if(j==0) { break; } } output(b); sort(b); output(b); } void sort(struct book b[]) { printf(根据书名倒序排序后\n); char temp[10]; for(int n=0;nn;i--) { if(strcmp(b[i].name,b[i-1].name)>0) { strcpy(temp,b[i].name); strcpy(b[i].name,b[i-1].name); strcpy(b[i-1].name,temp); } } } } void output(struct book b[]) { int sum=0; printf(******************\n); printf(排序前\n); printf(名称\t\t价格\t\t数量\t\t总价\n); for(int i=0;i
一、1.C 2.D 3.A 4.A 5.C 6.B 7.B 8.C 9.D 10.B 11.A 12.B 13.B 14.C 15.C 二、1.封装、继承、多态;2.传值、传址;3.Template;4.~student();5.私有;6.参数、返回值;7.优先级、结合性、运算顺序;8.代码的复用、MFC编程;9.X、Y;10.new
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1.Object
2.final
3.Object
4.this,super
一、读程序写结果
1.100
2.
数组a:123456,200,300
数组b:123456,200,300
数组b的长度: 3
3.
a=10
b=30
c=60
楼上出的有点鸡肋 对要考试的人来说是小菜一碟