车库一个车库有20辆
汽车要出售,一辆汽车的知名度
是:它的登记号它的品牌
关于#c++#的问题:车库一个车库有20辆汽车要出售,一辆汽车的知名度是
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- 不甘_ 2022-05-17 13:48关注
车对象:包含登记号,和品牌
car {
int number;
string pingpai;
}
车库对象包含:20个车
cartotal{
car car【20】;
}#include<stdio.h> #include <iostream> #include <stdlib.h> #include <time.h> using nhttps://img-mid.csdnimg.cn/release/static/image/mid/ask/773899967256113.png "#left") amespace std; class Student{ //创建对象 public: int price; int year; int pow; char* name ="car"; void print(){ cout<<name<<"的价格是"<<price<<",年份是"<<year<<",功率是"<<pow<<endl; } }; int main(){ Student stu; stu.price=100; stu.year=2001; stu.pow=100; stu.print(); //for循环创建20个车对象 Student arr[20] ; for(int i=0;i<20;i++){ Student stui; stui.price=i*100; stui.year=2001; srand((unsigned)time(NULL)); stui.pow=i*rand(); stui.print(); arr[i]= stui; } int total=0; int max=0; for(int i=0;i<20;i++){ //计算平均价格和总价格 total+=arr[i].price; if(arr[i].price>max){ max=arr[i].price; } } int pjz= total/20; printf("总价格是:%d\n", total); printf("平均价格是:%d\n",pjz); printf("最大的价格是:%d\n",max); }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 微信会员卡等级和折扣规则
- ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
- ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
- ¥15 gdf格式的脑电数据如何处理matlab
- ¥20 重新写的代码替换了之后运行hbuliderx就这样了
- ¥100 监控抖音用户作品更新可以微信公众号提醒
- ¥15 UE5 如何可以不渲染HDRIBackdrop背景
- ¥70 2048小游戏毕设项目
- ¥20 mysql架构,按照姓名分表
- ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分