Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int isPalindroma(int array[], int l){
- if (l%2 == 1){
- int lmetaArray = (int) l/2;
- for(int i = 1; i <=lmetaArray; i++){
- if (array[i-1] != array[l-i]){
- return 0;
- }
- }
- return 1;
- }
- else {
- for (int i = 1; i <l/2; i++){
- if (array[i-1] != array[l-i]){
- return 0;
- }
- }
- return 1;
- }
- }
- void main(){
- int array[] = {1,2,3,3,3,1};
- if (isPalindroma(array, 6)){
- printf("La sequenza data e' palindroma.");
- }
- else {
- printf("La sequenza data non e' palindroma.");
- }
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement