In: Computer Science
//Deepesh Malhotra, Jan 31
//This code is in C++ Language...
#include<bits/stdc++.h>
using namespace std;
int main()
{
//as my month number is 1 so array size will
be month number +10, hence 1+10=11
int arr[11];
//so user can enter 11 numbers in the
arr
int n,k=0;
cin>>n;
//checking if n is <= 11 then only we can
go further otherwise it will out of range of arr
if(n<=11)
{
//taking values from the
user
for(int i=0;i<n;i++)
cin>>a[i];
// this loop will give us
values which are invaid as values ranges from 1 to
31
for(int i=0;i<n;i++)
{
if(a[i] < 1
|| a[i] >31)
cout<<a[i]<<"Invalid number: Should be greater than 1
and less than 31";
}
//replacing every 3
adjacent elements of array with their sum
while(n>=1)
{
//as k
value will get changed below so we have to make it zero
everytime
k=0;
for(int
i=0;i<n;i=i+3)
{
sum=a[i] + a[i+1] + a[i+2];
a[k]=sum;
k++;
}
//updating value of n
n=k-1;
//if any
number is larger than 12 then replace it with the difference the
no. and 12
for(int
i=0;i<=n;i++)
{
ifa[i] > 12)
a[i]=a[i] - 12;
}
//repeating this process
till one single element is left
}
//printing the
result
cout<<a[0];
}