-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS41.cpp
53 lines (43 loc) · 991 Bytes
/
S41.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <string>
using namespace std;
void FillArray(int arr[100], int &arraylength)
{
arr[0] = 10;
arr[1] = 20;
arr[2] = 30;
arr[3] = 30;
arr[4] = 20;
arr[5] = 10;
arraylength = 6;
}
void PrintArray(int arr[100], int arraylength)
{
for (int i = 0; i < arraylength; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
bool CheckPalindrome(int arrSource[100], int arrSourceLength)
{
for (size_t i = 0; i < arrSourceLength; i++)
{
if (arrSource[i] != arrSource[arrSourceLength - i - 1])
{
return false;
}
}
return true;
}
int main(int argc, char const *argv[])
{
int arrSource[100], arrSourceLength = 0;
FillArray(arrSource, arrSourceLength);
PrintArray(arrSource, arrSourceLength);
if (CheckPalindrome(arrSource, arrSourceLength))
cout << " Yes Palindrome " << endl;
else
cout << " Not Palindrome " << endl;
return 0;
}