Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"stdafx.h"
- #include <iostream>
- #include <conio.h>
- using namespace std;
- bool polindrome1(unsigned char[], long);
- long setArray(unsigned char[], long);
- int main()
- {
- setlocale(LC_CTYPE, "Rus");
- const long maxSize = 10;
- unsigned char array[maxSize];
- long sizeArray;
- sizeArray = setArray(array, maxSize);
- if (polindrome1(array, sizeArray - 1))
- cout << "Введеная строка является палиндромом." << endl;
- else
- cout << "Введеная строка НЕ является палиндромом." << endl;
- return 0;
- }
- long setArray(unsigned char array[], long size)
- {
- long count = 0;
- cout << "Введите строку символов: " << endl;
- do
- {
- array[count] = cin.get();
- if (array[count] == 10)
- array[count] = '\0';
- count++;
- } while (array[count - 1] != '\0' && count < size);
- if (count == size)
- return count;
- else
- return count - 1;
- }
- bool polindrome1(unsigned char array[], long size)
- {
- long positionLetter = 0;
- bool polindrome = true;
- while (polindrome && (size - positionLetter) > 1)
- {
- if (array[positionLetter]
- != array[size - positionLetter])
- polindrome = false;
- else
- positionLetter++;
- }
- return polindrome;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement