DEV Community

Discussion on: Daily Challenge #44 - Mexican Wave

Collapse
lordapple profile image
LordApple • Edited on

c++

#include <iostream>
#include <vector>

std::vector<std::string> wave(std::string str){
    std::vector<std::string> returnVal;

    for(unsigned long i = 0; i < str.size(); ++i){
        if(str[i] < 'A' || str[i] > 'z'){
            continue;
        }
        std::string copy = str;
        copy[i] -= 32;
        returnVal.push_back(copy);
    }

    return returnVal;
}

int main(){
    for(const auto& word : wave("hello world")){
        std::cout << word << std::endl;
    }

    return 0;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
salma0110 profile image
salma0110

from where did you learn that u should use 32 , i didn't know that before
Thank you

Collapse
lainofthewired profile image
Lain-of-the-Wired

That's crazy.