Day2

[Day2]

1. IBM 빼기 1

문제 링크: https://www.acmicpc.net/problem/6321

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int count;
    cin >> count;
    string input;
    for(int i=0; i<count; i++){
        cin >> input;
        cout << "String #" << i+1 << "\n";
        for(int j=0; j<input.length(); j++){
            cout << (char)((input[j]-'A'+1)%26+'A');
        }
        cout << "\n\n";
    }
    return 0;
}

2. 비밀번호 발음하기

문제 링크: https://www.acmicpc.net/problem/4659

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    string input;

    while(1){
        bool result = true;
        bool vow = false;
        bool vow_check = false;
        int count = 0;
        cin >> input;
        if(input == "end") {
            break;
        }
        for(int i=0; i<input.length(); i++){
            if(i!=0){
                if(input[i-1]==input[i] && input[i]!='o' && input[i]!='e'){
                    result = false;
                    //cout << "3"; //test
                    break;
                }
            }
            if(input[i]=='a' || input[i]=='e' ||input[i]=='i' ||input[i]=='o' ||input[i]=='u'){
                if(vow==false){
                    count = 0;
                }
                vow = true;
                vow_check = true;
                ++count;
            }
            else{
                if(vow == true){
                    count = 0;
                }
                vow = false;
                ++count;
            }
            if(count == 3){
                result = false;
                //cout << "2"; //test
                break;
            }
            if(result == false){
                break;
            }
        }
        if(vow_check == false){
            //cout << "1"; //test
            result = false;
        }
        if(result == true){
            cout << "<" << input << "> is acceptable.\n";
        }
        else{
            cout << "<" << input << "> is not acceptable.\n";
        }
        result = true;
    }
    return 0;
}

3. 날짜 계산

문제 링크: https://www.acmicpc.net/problem/1476

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int e, s, m;
    cin >> e >> s >> m;
    int result=1;
    while(1){
        if((result-e)%15==0 && (result-s)%28==0 && (result-m)%19==0){
            cout << result;
            break;
        }
        result++;
    }
    return 0;
}