ppupil2

Q06-PRF192-PE-31.03

Mar 31st, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6.  
  7. int main() {
  8.   system("cls");
  9.   //INPUT - @STUDENT:ADD YOUR CODE FOR INPUT HERE:
  10.     int a[100], n;
  11.     bool check = true;
  12.    
  13.     scanf("%d", &n);
  14.     for (int i = 0; i<n; i++) {
  15.         scanf("%d", &a[i]);
  16.     }
  17.    
  18.     for (int i = 0; i<n; i++) {
  19.         if (a[i]%2 == 0) {
  20.             check = false;
  21.             break;
  22.         }
  23.     }
  24.     if (check == true && n>=2) {
  25.         int x;
  26.         if (n%2 == 1) x = n/2;
  27.         else x = n/2-1;
  28.         for (int i = 0; i<=x; i++) {
  29.             if (a[i] != a[n-1-i]) {
  30.                 check = false;
  31.                 break;
  32.             }
  33.         }
  34.     }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.   // Fixed Do not edit anything here.
  41.   printf("\nOUTPUT:\n");
  42.   //@STUDENT: WRITE YOUR OUTPUT HERE:
  43.     printf("%d", check);
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.   //--FIXED PART - DO NOT EDIT ANY THINGS HERE
  54.   printf("\n");
  55.   system ("pause");
  56.   return(0);
  57. }
Add Comment
Please, Sign In to add comment