Good Weather: GOODWEAT

Problem link: https://www.codechef.com/CU1PP0005/problems/GOODWEAT

Problem code: GOODWEAT

The weather report of Chefland is Good if the number of sunny days in a week is strictly greater than the number of rainy days.

Given 77 integers A1,A2,A3,A4,A5,A6,A7A1,A2,A3,A4,A5,A6,A7 where Ai=1Ai=1 denotes that the ithith day of week in Chefland is a sunny day, Ai=0Ai=0 denotes that the ithith day in Chefland is a rainy day. Determine if the weather report of Chefland is Good or not.

Solution:

#include <stdio.h>

int main(void) {
   int t;
   scanf("%d",&t);
   while(t--){
       int a[7],p=0,q=0;
       int i;
       for(i=0;i<7;i++){
           scanf("%d",&a[i]);
       }
       for(i=0;i<7;i++){
           if(a[i]==1)
             p++;
             else
             q++;
       }
       if(p>q)
       printf("yes\n");
       else
       printf("no\n");
   }
  return 0;
}
See also  Gold Mining