Advertisement
ppupil2

Q08-PRF192-PE-31.03

Mar 31st, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.24 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[7], mask[7] = {0};
  11.     int b[7], count[7] = {0};
  12.     int x = 0;
  13.    
  14.     for (int i = 0; i<7; i++) {
  15.         scanf("%d", &a[i]);
  16.     }
  17.    
  18.     for (int i = 0; i<7; i++) {
  19.         if (a[i]%2 == 0) {
  20.             mask[i] = 1;
  21.         }
  22.     }
  23.    
  24.     for (int i = 0; i<7; i++) {
  25.         if (mask[i] == 0) {
  26.             int j = 0;
  27.             for (j = 0; j<x; j++) {
  28.                 if (a[i] == b[j]) {
  29.                     count[j]++;
  30.                     break;
  31.                 }
  32.             }
  33.             if (j == x) {
  34.                 b[x] = a[i];
  35.                 count[x] = 1;
  36.                 x++;
  37.             }  
  38.         }  
  39.     }
  40.    
  41.     int maxcount = count[0];
  42.     for (int i = 1; i<x; i++) {
  43.         if (maxcount < count[i]) {
  44.             maxcount = count[i];
  45.         }
  46.     }
  47.    
  48.   // Fixed Do not edit anything here.
  49.   printf("\nOUTPUT:\n");
  50.   //@STUDENT: WRITE YOUR OUTPUT HERE:
  51.     int y;
  52.     if (x == 0) {
  53.         printf("No odd number.");
  54.     }
  55.     else {
  56.         for (int i = 0; i<x; i++) {
  57.             if (maxcount == count[i]) {
  58.                 printf("%d", b[i]);
  59.                 y = i;
  60.                 break; 
  61.             }
  62.         }
  63.         for (int i = y+1; i<x; i++) {
  64.             if (maxcount == count[i]) {
  65.                 printf(" %d", b[i]);
  66.             }
  67.         }
  68.     }
  69.    
  70.  
  71.  
  72.   //--FIXED PART - DO NOT EDIT ANY THINGS HERE
  73.   printf("\n");
  74.   system ("pause");
  75.   return(0);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement