Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- using namespace std;
- const int LEN = 1000;
- unsigned char rus(unsigned char a) {
- if (a >= 192 && a <= 223)
- return a + 32;
- return a;
- }
- void my_gets(unsigned char* ar, int l) {
- int i = 0;
- unsigned char a = getchar();
- while (a != '\n' && a != '.' && i < l && a != '!') {
- if (a != ' ' && a != ',' && a != '-' && a != '—') {
- ar[i] = rus(a);
- ++i;
- }
- a = getchar();
- }
- ar[i] = '\0';
- }
- void string_reverse(unsigned char* source, unsigned char * dest, int l){
- for (int i = 0; i < l; ++i)
- dest[i] = source[l - i - 1];
- dest[l] = '\0';
- }
- int check(unsigned char* source, unsigned char* rcopy, int l) {
- int flag = 1;
- for (int i = 0; i < l; ++i) {
- if (source[i] != rcopy[i]) {
- flag = 0;
- break;
- }
- }
- return flag;
- }
- int my_len(unsigned char* source) {
- int i = 0;
- while (source[i++] != '\0')
- ;
- return --i;
- }
- int main() {
- SetConsoleOutputCP(1251); //#include <windows.h>
- SetConsoleCP(1251);
- unsigned char source[LEN];
- unsigned char rcopy[LEN];
- my_gets(source, LEN);
- int len = my_len(source);
- string_reverse(source, rcopy, len);
- if (check(source, rcopy, len))
- cout << "Перевёртыш";
- else
- cout << "Не перевёртыш";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement