This is my approach. #include using namespace std; int main() { string str; cin >> str; int score = 0; int t, c, g; t = 0; c = 0; g = 0; for (int i = 0; i < str.size(); i++) { if (str[i] == 'C') { c += 1; } else if (str[i] == 'G') { g +=1; } else { t+=1; } } score += pow(t,2) + pow(g,2) + pow(c,2); while (t > 0 and c > 0 and g > 0) { t -= 1; c -= 1; g -= 1; score += 7; } cout
Love it =))))))
This is my approach.
#include
using namespace std;
int main()
{
string str;
cin >> str;
int score = 0;
int t, c, g;
t = 0;
c = 0;
g = 0;
for (int i = 0; i < str.size(); i++) {
if (str[i] == 'C') {
c += 1;
}
else if (str[i] == 'G') {
g +=1;
}
else {
t+=1;
}
}
score += pow(t,2) + pow(g,2) + pow(c,2);
while (t > 0 and c > 0 and g > 0) {
t -= 1;
c -= 1;
g -= 1;
score += 7;
}
cout