#include <iostream> #include <string> #include <stack> using namespace std; class gammal{ private: -string subject; public: -gammal(string s){ --subject = s; -} -string print(){ --return subject; -} }; int main() { -stack<gammal> g; -g.push(gammal("Final Exam")); -g.push(gammal("OOP")); -g.push(gammal("Algorithms")); -g.push(gammal("Data Structures")); -g.push(gammal("C++")); -g.push(gammal("C")); -while(!g.empty()){ --cout<<"Did you finish "; --cout<<g.top().print() <<"?"<<endl; --string answer; --cin>>answer; --if( answer == "yes"){ ---g.pop(); --} -} -cout<<endl<<"Congradulations You are now a software engineer"<<endl<<endl; }
.برنامج يطلب من المستخدم أن يدخل 10 أرقام ويسجل األرقام التي تم إدخالها على شكل Stack بحيث يوفر البرنامج للمستخدم عمل ) ()size(), top(), pop )لكن بدون استخدام أمر Stack الجاهز في اللغة )للمتفوقين(. مالحظة : الهدف من التمرين هو عمل )Stack Implementing.
Problem statement
The Gammal Tech file system keeps a log each time some user performs a change folder operation.
The operations are described below:
You are given a list of strings s[i] where is the operation performed by the user..
Input
1 <= s.length <= 103
2 <= s[i].length <= 10
Output
print the minimum number of operations needed to go back to the main folder after the change folder operations.