Security problem | Sololearn: Learn to code for FREE!

0

Security problem

my code fails in some test cases. can you help me understand where am I wrong? https://code.sololearn.com/cyXR5GVIoQ58/?ref=app

3/20/2022 9:17:04 PM

Francesco Famosi

2 Answers

New Answer

+2

$ can be the first or last character

+1

Use variable type "i" size_t instead of int since you are comparing two different value types: for(size_t i=0; i<piano_temp.length(); i++) Better yet, use an improved "for" loop: for(char a: piano_temp) if(a=='G'||a=='$'||a=='T')piano+=a; There are only two cases where an alarm should sound: T$ and $T ๐Ÿ˜‰