网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
08月11日漏签0天
c++吧 关注:628,376贴子:2,113,306
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 5回复贴,共1页
<<返回c++吧
>0< 加载中...

来个哥哥帮我看看哪里不对,球球了(一道电梯题

  • 只看楼主
  • 收藏

  • 回复
  • weee_www
  • &&
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
是一个多人电梯的,只需要上下就行
#pragma once
#pragma once
#include<iostream>
class elevator {
protected:
int pd;
public:
void mianban();
int panduan();
void fuzhi_pd(int x);
};
class person:public elevator{
protected:
int renshu;
int* floot_now=new int[renshu];
int* floot_dream=new int [renshu];
public:
void paixu_weizhi();
void fuzhi_weizhi(int a[], int b[]);
void fuzhi_renshu(int x);
};
class Advelevator :public person {
private:
int now=1;
int dream=1;
public:
int shuchu_pd();
void setFloorNumber();
void jiaohuan();
void fuzhi_dream();
void dream1();
};
#include"标头.h";
#include<iostream>
#include<Windows.h>
#include<algorithm>
using namespace std;
void elevator::mianban() {
cout << "---请选择操作----" << endl;
cout << "| 1.上升 |" << endl;
cout << "| 2.下降 |" << endl;
cout << "-----------------" << endl;
}
int elevator::panduan() {
if (pd == 1)
return 1;
else if (pd == 2)
return 2;
else
return 4;
}
void elevator::fuzhi_pd(int x) {
pd = x;
}
void person::fuzhi_renshu(int x) {
renshu = x;
}
void person::fuzhi_weizhi(int a[],int b[]) {
for (int i = 0; i < renshu; i++) {
floot_now[i] = a[i];
floot_dream[i] = b[i];
}
}
void person::paixu_weizhi() {
if (panduan() == 1) {
sort(floot_now, floot_now+99);
sort(floot_dream, floot_dream+99);
}
if (panduan() == 2) {
sort(floot_now, floot_now + 99, greater<int>());
sort(floot_dream, floot_dream + 99, greater<int>());
}
}
int Advelevator::shuchu_pd() {
int i = 0;
if (panduan() == 4) {
cout << "您的选择有误,不能操作!" << endl << endl;
return 0;
}
return 1;
}
void Advelevator::setFloorNumber() {
cout << "当前电梯停在" << now<<"层" << endl;
if (panduan() == 1) {
for (int i = now; i <= dream; i++) {
cout << "--" << i << "--" << endl;
Sleep(500);
for (int j = 0; j < renshu; j++) {
if (floot_now[j] == i || floot_dream[j] == i) {
cout << "第" << i << "层到了!!!" << endl;
}
}
}
for (int j = 0; j < renshu; j++) {
if (floot_now[j] > 10 || floot_now[j] < 1 || floot_dream[j]>10 || floot_dream[j] < 1) {
cout << "您选择的楼层不存在!" << endl << endl;
}
}
}
if (panduan() == 2) {
for (int i = now; i >= dream; i--) {
cout << "--" << i << "--" << endl;
Sleep(500);
for (int j = 0; j < renshu; j++) {
if (floot_now[j] == i || floot_dream[j] == i) {
cout << "第" << i << "层到了!!!" << endl;
}
}
}
for (int j = 0; j < renshu; j++) {
if (floot_now[j] > 10 || floot_now[j] < 1 || floot_dream[j]>10 || floot_dream[j] < 1) {
cout << "您选择的楼层不存在!" << endl << endl;
}
}
}
}
void Advelevator::jiaohuan() {
int t;
t = now;
now = dream;
dream = t;
}
void Advelevator::fuzhi_dream() {
int i = 0;
if (panduan() == 1) {
for (i = 0; i < renshu; i++) {
if (floot_dream[i] >= 1 || floot_dream[i] <= 10) {
dream = floot_dream[i];
}
}
}
if (panduan() == 2) {
for (i = 0; i < renshu; i++) {
if (floot_dream[i] >= 1 || floot_dream[i] <= 10) {
dream = floot_dream[i];
}
}
}
}
void Advelevator::dream1() {
cout << dream << endl;
}
#include"标头.h";
#include<iostream>
#include<Windows.h>
#include<ctime>
#include<algorithm>
using namespace std;
int main() {
int pd;
time_t shijian = time(0);
struct tm t;
localtime_s(&t, &shijian);
cout << "今天是";
cout << t.tm_year + 1900 << "年" << t.tm_mon + 1 << "月" << t.tm_mday << "日" << endl;
cout << "该电梯一共10层,欢迎您的使用!" << endl << endl;
Advelevator c;
c.mianban();
cin >> pd;
c.fuzhi_pd(pd);
while (c.panduan()!=3) {
cout << "请输入乘坐电梯的人数" << endl;
int renshu;
cin >> renshu;
cout << "请输入每个人所在的楼层和目的层" << endl;
int* floot_now = new int[renshu];
int* floot_dream = new int[renshu];
for (int i = 0; i < renshu; i++) {
cin >> floot_now[i] >> floot_dream[i];
}
if (c.shuchu_pd() == 1) {
c.fuzhi_renshu(renshu);
c.fuzhi_weizhi(floot_now,floot_dream);
c.paixu_weizhi();
c.fuzhi_dream();
c.dream1();
c.setFloorNumber();
c.jiaohuan();
}
c.mianban();
cin >> pd;
c.fuzhi_pd(pd);
delete[]floot_now;
delete[]floot_dream;
}
}


  • zla0402
  • ^
    8
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
这个具体是什么问题,太长了,没耐心读


2025-08-11 20:29:36
广告
不感兴趣
开通SVIP免广告
  • 我不会感到失败
  • ^
    8
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
6


  • 贴吧用户_QS4D58K
  • ?:
    4
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
定位问题再来问


  • 贴吧用户_GZXJ2UC
  • &&
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
太长了,不看


  • 让我看你法语正不正常
  • <
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
就不能把编译器的错误截出来


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 5回复贴,共1页
<<返回c++吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示