"프로그래머스 181926 수 조작하기 1"의 두 판 사이의 차이

(새 문서: ==개요== {{프로그래머스|레벨=0|페이지=2}})
 
1번째 줄: 1번째 줄:
==개요==
==개요==
{{프로그래머스|레벨=0|페이지=2}}
{{프로그래머스|레벨=0|페이지=2}}
==C++==
<syntaxhighlight lang='cpp'>
#include <string>
#include <vector>
using namespace std;
int solution(int n, string control) {
    for(int i=0; i<control.length(); i++) {
        switch(control[i]) {
            case 'w': n++; break;
            case 's': n--; break;
            case 'd': n+=10; break;
            case 'a': n-=10; break;
        }
    }
    return n;
}
</syntaxhighlight>

2023년 9월 4일 (월) 02:19 판

1 개요

프로그래머스 181926 수 조작하기 1


2 C++

#include <string>
#include <vector>

using namespace std;

int solution(int n, string control) {
    for(int i=0; i<control.length(); i++) {
        switch(control[i]) {
            case 'w': n++; break;
            case 's': n--; break;
            case 'd': n+=10; break;
            case 'a': n-=10; break;
        }
    }
    return n;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}