Færdiggjort

C++ code using data structures

The task is to write a function that checks if strings are balanced. Your code has to have a function named is_balanced which takes one argument: a std::string and returns a boolean. It should return true if the string is balanced, and false otherwise.

The function has to read the string character by character.

The function does not read the string multiple times.

If the function reads a character ', it ignores next characters until it reads the next '.

If the function reads the character ", it ignores next characters until it reads the next " character.

If the function reads the character ( or [, it pushes it on top of a stack.

If the function reads a )it checks the top of the stack and if it is equal to (, it deletes the topmost element of the stack -- otherwise it returns false.

If the function reads a ]it checks the top of the stack and if it is equal to [, it deletes the topmost element of the stack -- otherwise it returns false.

It ignores all other characters.

If after reading the whole string the stack is empty then the function returns true. If it is not empty, the function has to return false.

Examples

std::string s = "asdf";

std::cout << std::boolalpha;

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "()";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "([])";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "([)]";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "[()]";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "[()";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "[(";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "[(([])[()])]";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "[(' ')]";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "[('[')]";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "[('[()')]";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "[('[()')(\")\")]";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "\"()[]";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "\"'''\"";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "'''";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "\"\"\"";

std::cout << s << ": " << is_balanced(s) << std::endl;

s = "'\"'\"\"";

std::cout << s << ": " << is_balanced(s) << std::endl;

Should print:

asdf: true

(): true

([]): true

([)]: false

[()]: true

[(): false

[(: false

[(([])[()])]: true

[(' ')]: true

[('[')]: true

[('[()')]: true

[('[()')(")")]: true

"()[]: false

"'''": true

''': false

""": false

'"'"": true

more about project pm

Evner: C programmering, C++ Programmering, Software Arkitektur

Se mere: graph data structure c++ source code, data structures programs in java, data structures in c++, data structure program examples, data structures and algorithms in c++, data structure program examples in c, data structure programs in c++ pdf, data structure in c++ by yashwant kanetkar pdf, sorting techniques in data structures using c, introduction to data structures using c, data structures with c using stl, data structures using c tutorial, data structures using c online tutorial, c algorithms and data structures, list project using data structures, project using data structures, project list using data structures, write search query using data structures java, java projects using data structures, reading using data excel

Om arbejdsgiveren:
( 2 bedømmelser ) Lodz, Poland

Projekt ID: #17163580

Tildelt til:

ansarias21

I have 2 years of working exeperiance in C++.

zł55 PLN på 1 dag
(5 bedømmelser)
1.2

22 freelancere byder i gennemsnit zł78 på dette job

liangjongai

Hi! I'm interesting your project very well. I am a full time devloper. I am mastering c++ and I'm a good Mathematician. And also I have many experience and good skill about data structure algorithm development. L Flere

zł90 PLN på 1 dag
(248 bedømmelser)
7.5
xzan88

Hi, I have over 10 years of experience in C/C++ programming. I have read the description. I can finish this today. Please message me.

zł90 PLN på 1 dag
(98 bedømmelser)
6.2
idleswell

Hello, I have 25 years experience programming in C++. I will create a C++ program with an is_balanced function according to the attached specifications. A milestone payment for the full budget for this project mu Flere

zł113 PLN in 3 dage
(184 bedømmelser)
6.1
vanilladevs

Hello there, lots of experience teaching algorithms and data structures at uni level with C/C++. Let me know the deadline of this balanced string task to see if I can help. Cheers!

zł89 PLN på 1 dag
(46 bedømmelser)
5.6
BestPartner4You

Hi Sir, I am a super C++ developer and have 7 years of enough experience in this kinds of projects, so I can help you. I checked your all requirements and understood what you want. I will provide you best quality wor Flere

zł115 PLN på 1 dag
(15 bedømmelser)
4.9
zł80 PLN på 1 dag
(38 bedømmelser)
4.9
zł105 PLN in 2 dage
(37 bedømmelser)
4.8
carlosgottberg

Hi, I pretty much have the thing figured out. I've worked with C++ for quite a while and it's not actually that difficult. I'm available for starting asap.

zł75 PLN på 1 dag
(10 bedømmelser)
4.2
zł85 PLN på 1 dag
(20 bedømmelser)
4.1
Nerdulent

hi mate....by when do you need the project completed? thanks :)

zł100 PLN på 1 dag
(7 bedømmelser)
2.8
athulskarun

Hello. I'm a Computer Engineer with 8+ years experience in C++ and C Programming. From our description, I came to know that this is a balanced parenthesis question and I can help you with it. Lets discuss more through Flere

zł75 PLN på 1 dag
(4 bedømmelser)
2.4
Hasham241

your work is very for me, i hope i will do this as soon as [login to view URL] more contact me in private chat..........

zł60 PLN på 1 dag
(3 bedømmelser)
1.7
swathi8118

Hi I am a software developer with 6+ years of experience. I mainly work on c++. I would like to discuss more about the project. Looking forward for a positive reply

zł55 PLN på 1 dag
(1 bedømmelse)
1.0
zł45 PLN in 2 dage
(0 bedømmelser)
0.0
zł65 PLN på 1 dag
(0 bedømmelser)
0.0
zł55 PLN på 1 dag
(0 bedømmelser)
0.0
RisingStar514

Hello How are you I read your job description carefully I have many good experiences in C++ Programming and Algorithm I have take part several in ACM and CodeChef Contest for Algorithm I can quickly your job in s Flere

zł75 PLN på 1 dag
(0 bedømmelser)
0.0
moussaz

Hi I'm a c++ programmer with more then 2 years of experience Your function is easy to build You can contact me for detail

zł95 PLN på 1 dag
(0 bedømmelser)
0.0
vasilyalevizos

Hi, I have up to 5 years of experience in c++. Please, don't hesitate to ask me if you are interesting and provide me full details on what you need me to do. Thanks. Have a great day.

zł70 PLN in 5 dage
(0 bedømmelser)
2.5
gurmeet1986

Hi, I have already worked on similar assignments although it is first job on this site but I was involved in this type work with local client. I am free in these days and can pick this task up. Thanks

zł90 PLN in 3 dage
(0 bedømmelser)
0.0