Tamamlanmış

C++ code using data structures 2

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.

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

Beceriler: C Programlama, C++ Programlama, Yazılım Mimarisi

Daha fazlasını gör: data structure program examples, c++ stack program example, data structure programs in c++ pdf, stack in data structure, data structures using c++ programs download, data structures programs in c++, data structures and algorithms in c++, c++ data structures book, 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

İşveren Hakkında:
( 0 değerlendirme ) Lodz, Poland

Proje NO: #17165181

Seçilen:

neos94

Hello, I am very experienced with algorithmic problem solving and can deliver this within minutes :) I have been in competitive programming for 8 years and I took part in International Olympiad in Informatics, which Daha Fazla

1 gün içinde %selectedBids___i_sum_sub_4%%project_currencyDetails_sign_sub_5% PLN
(0 Değerlendirme)
0.0

Bu iş için 13 freelancer ortalamada zł71 teklif veriyor

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 algorithm development. Let's go ahead w Daha Fazla

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% PLN
(231 Değerlendirme)
7.1
bormaa

Dear sir, iam interested in your project i can finish it easily with high quality with least price because iam building my profile. I can provide many design which can satisfy your impression and achieve what you want. Daha Fazla

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% PLN
(8 Değerlendirme)
4.8
kalyanprakash4

please discuss .........................................................................................................................................................

in %bids___i_period_sub_35% gün içinde105%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(16 Değerlendirme)
4.1
junaidlodhi6

i am an expert in c++... i can give you in 5 hours... looking forward to get some response... thanks!

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% PLN
(16 Değerlendirme)
3.6
rabnawazjansher8

hi , i can do your C++ assignment .. and i have already done many assignments related to data structure. i have past experience of 3 years. let discuss over chat thanks

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% PLN
(12 Değerlendirme)
3.4
Davepsingh23

Hello, I have my expertise in C++ and C and I can assure you that I have the right kind of experience and skills for this job. I have 6+ year of experience and these years I have created various projects like Dat Daha Fazla

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% PLN
(2 Değerlendirme)
2.8
in %bids___i_period_sub_35% gün içinde40%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(1 Yorum)
1.9
mashreghali

Hi, I have done a similar project before. I have good knowledge of C++ and data structures. I can do your project for you in 1 day.

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% PLN
(1 Yorum)
0.8
durgesh8527

Hello Sir/Mam, I have read your post requirement for the " task is to write a function that checks if strings are balanced. ". Now I have some questions to clear the things for this project. I am full time freelancer h Daha Fazla

in %bids___i_period_sub_35% gün içinde75%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(0 Değerlendirme)
0.0
1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% PLN
(0 Değerlendirme)
0.0
arazos

Hello, I wrote the code for the previous one just for fun. The code works completely fine for all inputs.

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% PLN
(0 Değerlendirme)
0.0
kojecka

Greetings. I have experience teaching data structures and programming classes for a long time (15+ years). So, I have full confidence in delivering your code as required. Looking forward to working with you.

in %bids___i_period_sub_35% gün içinde85%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(0 Değerlendirme)
0.0