WRONG ANSWER :TONYFOOD ,PLEASE GUIDE


#1

#include <stdio.h>

int main() {
int t,i,j,a[100],avg,sum=0,count=0,tot=0;
scanf("%d",&t);
for(i=0;i<t;i++)
{scanf("%d",&a*);
sum=sum+a*;
}
avg=sum/3;
for(i=0;i<t;i++)
{if(a*==avg)
count++;
a*==0;
}
for(i=0;i<t;i++)
{
for(j=i;j<t;j++)
{ tot=tot+a[j];
if(tot==avg)
{count++;}}}
if(count==3)
printf(“Yes
%d”,avg);
else printf("No
");
return 0;
}

//WHERE IS MY CODE WRONG???


#2

Its very hard to read your code, use external code sharing sites or markup to share your code instead of directly copy pasting it.

Anyway refer to this link for TONYFOOD: https://www.geeksforgeeks.org/partition-set-k-subsets-equal-sum/ (set k = 3)


#3

Here is his well-indented code - https://ideone.com/63YoPy