查找EXIT_HELP

report zexit_help .
tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
tables : tstct.
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
parameters : p_tcode like tstc-tcode obligatory.

select single * from tstc where tcode eq p_tcode.
if sy-subrc eq 0.
select single * from tadir where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.
move : tadir-devclass to v_devclass.
if sy-subrc ne 0.
select single * from trdir where name = tstc-pgmna.
if trdir-subc eq 'F'.
select single * from tfdir where pname = tstc-pgmna.
select single * from enlfdir where funcname =
tfdir-funcname.
select single * from tadir where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name eq enlfdir-area.

move : tadir-devclass to v_devclass.
endif.
endif.
select * from tadir into table jtab
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.
select single * from tstct where sprsl eq sy-langu and
tcode eq p_tcode.
format color col_positive intensified off.
write:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
if not jtab[] is initial.
write:/(95) sy-uline.
format color col_heading intensified on.
write:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
write:/(95) sy-uline.
loop at jtab.
select single * from modsapt
where sprsl = sy-langu and
name = jtab-obj_name.
format color col_normal intensified off.
write:/1 sy-vline,
2 jtab-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table jtab.
skip.
format color col_total intensified on.
write:/ 'No of Exits:' , sy-tfill.
else.
format color col_negative intensified on.
write:/(95) 'No User Exit exists'.
endif.
else.
format color col_negative intensified on.
write:/(95) 'Transaction Code Does Not Exist'.
endif.

at line-selection.
get cursor field field1.
check field1(4) eq 'JTAB'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen.

#include<iostream> #include<string> #include<sstream> using namespace std; class car { public: string chepai; string time_enter; string time_exit; int hour; int min; bool flag; // true表示进入停车场,false表示还在等待区 car(string cp, string te, bool f) { chepai = cp; time_enter = te; flag = f; std::istringstream iss(te); char colon; iss >> hour >> colon >> min; } void display() { //cout << "车牌号: " << chepai << ", 进入时间: " << time_enter << endl; if (min < 10) cout << "车牌号: " << chepai << ", 进入时间: " << hour << ":0" << min << endl; else { cout << "车牌号: " << chepai << ", 进入时间: " << hour <<":"<<min<< endl; } } void settime_enter(string te) { time_enter = te; std::istringstream iss(te); char colon; iss >> hour >> colon >> min; } }; bool time_panduan(string a) { int hour_a, min_a; char colon; std::istringstream iss(a); iss >> hour_a >> colon >> min_a; if (hour_a < 0 || hour_a > 23 || min_a < 0 || min_a > 59) { return false; } return true; } bool chepai_panduan(string a) { if (a.length() != 5) { return false; } for (char c : a) { if (!isalnum(c)) { return false; } } return true; } void jisuanfeiyong(int hour_enter, int min_enter, int hour_exit, int min_exit) { int hour_chazhi = hour_exit - hour_enter; int min_chazhi = min_exit - min_enter; if (min_chazhi < 0) { hour_chazhi--; min_chazhi += 60; } if (min_chazhi > 0) { hour_chazhi++; } int total_fee = hour_chazhi * 5; cout << "停车时间: " << hour_chazhi << "小时, 停车费用: " << total_fee << "元" << endl; } class parkinglot { public: car* head_car; parkinglot* next; parkinglot() { head_car = nullptr;next = nullptr; } ~parkinglot(){} void car_add(parkinglot*a,car* p) { //判断该车是否已经在停车场内 string cp = p->chepai; parkinglot* wa = a; while (wa != nullptr) { if (wa->head_car != nullptr && wa->head_car->chepai == cp) { cout << "该车已在停车场内,无法重复进入!" << endl; return; } wa = wa->next; } cout << "车辆已进入停车场!\n" << endl; if (head_car == nullptr) { head_car = p; return; } parkinglot* help = a; while (help->next != nullptr) { help = help->next; } help->next = new parkinglot(); help->next->head_car = p; } void car_exit(parkinglot*a,string cp,string likai) { parkinglot* help = a; //把离开时间的小时和分钟提取出来 std::istringstream iss(likai); char colon; int exit_hour, exit_min; iss >> exit_hour >> colon >> exit_min; if (help == nullptr) { cout << "停车场为空,无法离开!" << endl; return; } if (help->head_car->chepai == cp) { if (help->next == nullptr) { a->head_car = nullptr; cout << "车辆已离开停车场!\n" << endl; //计算停车费用 jisuanfeiyong(help->head_car->hour, help->head_car->min, exit_hour, exit_min); return; } a = a->next; cout << "车辆已离开停车场!\n" << endl; } else { parkinglot* prev = help; help = help->next; while (help != nullptr) { if (help->head_car->chepai == cp) { prev->next = help->next; cout << "车辆已离开停车场!\n" << endl; //计算停车费用 jisuanfeiyong(help->head_car->hour, help->head_car->min, exit_hour, exit_min); return; } prev = help; help = help->next; } cout << "该车不在停车场内,无法离开!" << endl; return; } } void diplay() { parkinglot* help = this; if (help->head_car == nullptr) { cout << "停车场为空!" << endl; return; } while (help != nullptr) { help->head_car->display(); help = help->next; } } int getcount() { int count = 0; parkinglot* help = this; while (help != nullptr) { count++; help = help->next; } return count; } bool iffound(parkinglot* a, string cp) { parkinglot* help = a; while (help != nullptr) { if (help->head_car->chepai == cp) { return true; } help = help->next; } return false; } int gettime_enter(parkinglot*a,string cp) { parkinglot* help = a; while (help != nullptr) { if (help->head_car->chepai == cp) { return help->head_car->hour * 60 + help->head_car->min; } help = help->next; } } }; class waitingarea { public: car* head_car; waitingarea* next; waitingarea() { head_car = nullptr;next = nullptr; } ~waitingarea() {} void car_add(waitingarea* a, car* p) { if (head_car == nullptr) { head_car = p; return; } waitingarea* help = a; while (help->next != nullptr) { help = help->next; } help->next = new waitingarea(); help->next->head_car = p; } void diplay() { waitingarea* help = this; if (help->head_car == nullptr) { cout << "等待区为空!" << endl; return; } while (help != nullptr) { help->head_car->display(); help = help->next; } } int getcount() { int count = 0; waitingarea* help = this; while (help != nullptr) { count++; help = help->next; } return count; } void car_exit(waitingarea* a, string cp) { waitingarea* help = a; if (help == nullptr) { cout << "等待区为空!" << endl; return; } if (help->head_car->chepai == cp) { if (help->next == nullptr) { a->head_car = nullptr; cout << "车辆已离开等待区!\n" << endl; return; } a = a->next; } else { waitingarea* prev = help; help = help->next; while (help != nullptr) { if (help->head_car->chepai == cp) { prev->next = help->next; return; } prev = help; help = help->next; } cout << "该车不在等待区内,无法离开!" << endl; return; } cout << "车辆已离开等待区!\n" << endl; } bool iffound(waitingarea* a, string cp) { waitingarea* help = a; while (help != nullptr) { if (help->head_car->chepai == cp) { return true; } help = help->next; } return false; } }; int main() { parkinglot* lot = new parkinglot(); waitingarea* wait = new waitingarea(); cout << "欢迎使用停车管理系统\n" << endl; cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; int choice; cin >> choice; kaishixuanze: if (choice == 5) { return 0; } else if (choice < 1 || choice > 4) { cout << "请根据您的需要输入正确的选项!" << endl; cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; cin >> choice; goto kaishixuanze; } else if (choice == 1) { cout << "停车场情况如下:" << endl; lot->diplay(); cout << "等待区情况如下:" << endl; wait->diplay(); cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; cin >> choice; } else if (choice == 2) { cout << "请输入车牌号(五位数车牌号):"; jinruschepai: string chepai; cin >> chepai; if (!chepai_panduan(chepai)) { cout << "车牌号格式错误,请重新输入!\n" << endl; goto jinruschepai; } cout << "请输入进入时间:"; jinrushijian: string time_enter; cin >> time_enter; if (!time_panduan(time_enter)) { cout << "时间格式错误,请重新输入!\n" << endl; goto jinrushijian; } if (lot->getcount() >= 3) { if (wait->getcount() >= 3) { cout << "等待区已满,无法进入停车场,请稍后再试!\n" << endl; cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; cin >> choice; goto kaishixuanze; } cout << "停车场已满,车辆进入等待区!\n" << endl; car* newcar = new car(chepai, time_enter, false); wait->car_add(wait, newcar); cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; cin >> choice; goto kaishixuanze; } car* newcar = new car(chepai, time_enter, true); lot->car_add(lot, newcar); cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; cin >> choice; } else if (choice == 3) { cout << "请输入要离开的车牌号:"; string chepai; cin >> chepai; cout << "请输入离开时间:"; int hour_enter = lot->gettime_enter(lot, chepai); int hour_exit, min_exit; jinrushijian2: string time_exit; cin >> time_exit; if (!time_panduan(time_exit)) { cout << "时间格式错误,请重新输入!\n" << endl; goto jinrushijian2; } std::istringstream iss(time_exit); char colon; iss >> hour_exit >> colon >> min_exit; int total_exit = hour_exit * 60 + min_exit; if (total_exit < hour_enter) { cout << "离开时间不能早于进入时间,请重新输入!\n" << endl; goto jinrushijian2; } lot->car_exit(lot, chepai, time_exit); //判断等待区是否有车,有则进入停车场 if (wait->head_car != nullptr) { car* waitcar = wait->head_car; //设置等候区进入停车场的时间 waitcar->settime_enter(time_exit); wait->car_exit(wait, waitcar->chepai); lot->car_add(lot, waitcar); cout << "等待区有车,已将等待区第一辆车进入停车场!\n" << endl; } cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; cin >> choice; } else if (choice == 4) { cout << "请输入要查找的车牌号:"; string chepai; cin >> chepai; if (lot->iffound(lot, chepai)) { cout << "该车在停车场内!" << endl; } else if (wait->iffound(wait, chepai)) { cout << "该车在等待区内!" << endl; } else { cout << "该车不在停车场和等待区内!" << endl; } cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; cin >> choice; } else { cout << "请根据您的需要输入正确的选项!" << endl; cout << "请选择操作:\n1.查看停车场情况\n2.车辆进入\n3.车辆离开\n4.查找车辆\n5.退出系统\n"; cin >> choice; } goto kaishixuanze; } 其中car_enter和car_exit的时间复杂度
最新发布
11-03
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值