### 通知事項 11/10/2023 ### 1. 複習時間 ##  ## 請寫一個struct給baller,它包含了血量、dodgeball數量、球的傷害 :::spoiler **P1答案** ``` struct baller { int hp, dodgeball_count, ball_dmg; }; ``` }; ::: *** ### 2. 複習(hard) ## 請寫出一個把字串的字母,大寫改成小寫、小寫改成大寫的程式 ## eg. hELLo ---> HellO ## Hint: 用 ASCII :::spoiler **P2答案** ``` #include <iostream> #include <string> int main() { std::string str; std::cin >> str; for (int i=0; i<str.length(); i++) { if ((int)str[i] > 90) str[i] = str[i] - 32; else str[i] = str[i] + 32; } std::cout << str; } ``` ::: ***
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up