CP-1.301 - C++ Intro

Поділитися
Вставка
  • Опубліковано 28 жов 2024

КОМЕНТАРІ • 2

  • @vannguyennguyen7731
    @vannguyennguyen7731 3 роки тому +1

    Love it =))))))

  • @davinmercier2895
    @davinmercier2895 2 роки тому

    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