0

Hello I'm new at coding I want to make my career as a coder and a web developer this is my code please help me to understand how we get maxheight

#include <bits/stdc++.h>
using namespace std;

    int main() {
        int height = -1,len,heights[26];
        string str;
        for(int i = 0; i < 26; i++)cin >> heights[i];
        cin >> str;
        len = str.length();
        for(int i = 0; i < len; i++){
            if(heights[str[i]-'a'] > height)height = heights[str[i]-'a'];
        }
        cout << len*height << endl;
        return 0;
    }
  • Are you trying to figure out the largest value in `heights`? – fortytoo Sep 01 '21 at 04:40
  • Please explain what this code is trying to do, what is your expected result, and what is the result this code produces and how it deviates from your expected result. – fortytoo Sep 01 '21 at 04:45
  • Did you try to find the problem with a debugger? – Rene Sep 01 '21 at 06:07
  • [Why should I not #include ?](https://stackoverflow.com/q/31816095/3422102) – David C. Rankin Sep 01 '21 at 07:00
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 03 '21 at 12:04

0 Answers0