//compilation on code shef
prog.cpp: In function ‘int main()’:
prog.cpp:16:7: error: expected ‘(’ before ‘each’
for each (char c in s)
^
prog.cpp:16:13: error: expected primary-expression before ‘char’
for each (char c in s)
^
prog.cpp:16:24: error: ‘each’ was not declared in this scope
for each (char c in s)
^
prog.cpp:17:3: error: expected ‘;’ before ‘{’ token
{
^
prog.cpp:52:1: error: expected primary-expression at end of input
}
^
prog.cpp:52:1: error: expected ‘;’ at end of input
prog.cpp:52:1: error: expected primary-expression at end of input
prog.cpp:52:1: error: expected ‘)’ at end of input
prog.cpp:52:1: error: expected statement at end of input
prog.cpp:52:1: error: expected ‘}’ at end of input
prog.cpp:8:6: warning: unused variable ‘count’ [-Wunused-variable]
int count = 0;
^
prog.cpp:52:1: error: expected ‘}’ at end of input
}
^
//My Program
#include
#include
using std::string;
int main()
{
int t;
int count = 0;
std::cin >> t;
string s;
while (t != 0)
{
std::cin >> s;
for each (char c in s)
{
if (c == 'A')
{
count++;
}
else if (c == 'D')
{
count++;
}
else if (c == 'O')
{
count++;
}
else if (c == 'P')
{
count++;
}
else if (c == 'R')
{
count++;
}
else if (c == 'Q')
{
count++;
}
else if (c == 'B')
{
count += 2;
}
}
std::cout << count;
count = 0;
}
return 0;
}