๐Ÿ“ฆ Chango/๐Ÿฃ EDOC

[๊ตฌ๋ฆ„][C++] 10ํšŒ E-PPER 2๋ฒˆ : OX ํ€ด์ฆˆ

์„ ๋‹ฌ 2021. 9. 15. 17:24
๋ฐ˜์‘ํ˜•

https://level.goorm.io/exam/123589/10%ED%9A%8C-e-pper-ox-%ED%80%B4%EC%A6%88/quiz/1

 

๊ตฌ๋ฆ„LEVEL

์ฝ”๋”ฉํ…Œ์ŠคํŠธ์—์„œ ๊ฐ€์žฅ ๋†’์€ ๋น„์ค‘์„ ์ฐจ์ง€ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ์ œ์ž‘ํ•˜๊ณ  ํ’€์ดํ•  ์ˆ˜ ์žˆ๋Š” ์˜จ๋ผ์ธ ์ €์ง€ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค. ๊ธฐ์—…์—์„œ ์„ ํ˜ธํ•˜๋Š” C, C++, ํŒŒ์ด์ฌ(Python), ์ž๋ฐ”(Java), ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ(Javascript) ์ด

level.goorm.io

 

#include <iostream>
#include <vector>

using namespace std;

int main() {
    char input[100];
    cin >> input;
    
    int ans = 0;
    
    int tmp = 1;
    for(int i = 0; ; i++){
        if(input[i] == 'O'){
        ans += tmp;
        tmp++;
        }
        else if(input[i] == 'X') {
        tmp = 1;
        }
        else {
            break;
        }
    }
    
    cout << ans;
    
    return 0;
}
๋ฐ˜์‘ํ˜•