[ create a new paste ] login | about

Link: http://codepad.org/RD23fPm1    [ raw code | output | fork ]

C++, pasted on Nov 25:
#include <algorithm>

int main()
{
    SetConsoleCP(1251);
    SetConsoleOutputCP(1251);
    int i = 0, k;
    char ABC[] = { 'А','Б','В','Г','Д','Е','Ж','З','И',
                'Й','К','Л','М','Н','О','П','Р','С',
                'Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ',
                'Ы','Ь','Э','Ю','Я','_','.',',','0',
                '1','2','3','4','5','6','7','8','9' };
    char msg[80];
    cout << "Введите сообщение, которое будет закодировано: " << endl;
    cin.getline(msg, 80);
    cout << "\nВведите сдвиг:" << endl;
    cin >> k;
    cout << endl;
    char* begin = ABC;
    char* end = ABC + sizeof(ABC);
    for (; msg[i]; ++i)
    {
        char* ch = find(begin, end, msg[i]);
        if (ch != end) msg[i] = *(begin + (ch - begin + k) % sizeof(ABC));
    }
    cout << "Полученное закодированное сообщение: " << endl;
    cout << msg << endl;
    return 0;
}


Output:
Line 19: error: multi-character character constant
Line 24: error: multi-character character constant
Line 29: error: multi-character character constant
Line 34: error: multi-character character constant
Line 39: error: multi-character character constant
Line 44: error: multi-character character constant
Line 49: error: multi-character character constant
Line 54: error: multi-character character constant
Line 59: error: multi-character character constant
Line 16: error: multi-character character constant
Line 21: error: multi-character character constant
Line 26: error: multi-character character constant
Line 31: error: multi-character character constant
Line 36: error: multi-character character constant
Line 41: error: multi-character character constant
Line 46: error: multi-character character constant
Line 51: error: multi-character character constant
Line 56: error: multi-character character constant
Line 16: error: multi-character character constant
Line 21: error: multi-character character constant
Line 26: error: multi-character character constant
Line 31: error: multi-character character constant
Line 36: error: multi-character character constant
Line 41: error: multi-character character constant
Line 46: error: multi-character character constant
Line 51: error: multi-character character constant
Line 56: error: multi-character character constant
Line 16: error: multi-character character constant
Line 21: error: multi-character character constant
Line 26: error: multi-character character constant
Line 31: error: multi-character character constant
Line 36: error: multi-character character constant
In function 'int main()':
Line 5: error: 'SetConsoleCP' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: