#include<stdio.h>
void main()
{
int i,n,sum,f,p,t;
scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
for(i=0,sum=0;i<n;i++)
{
scanf("%d",&p);
sum=p+sum;
}
printf("%d",n-(sum/(n-1)));
}
}i am getting SIGSTTP error plz find,
#include<stdio.h>
void main()
{
int i,n,sum,f,p,t;
scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
for(i=0,sum=0;i<n;i++)
{
scanf("%d",&p);
sum=p+sum;
}
printf("%d",n-(sum/(n-1)));
}
}i am getting SIGSTTP error plz find,
Hi!!
First of all from next time please also include a link to the original question.
Second instead of copy pasting the code here, provide a link to the code so that it is clearly visible(Not mashed up).
A few corrections to be made -
Note that from the given Constrains it is possible that there are 10^5 students who report 10^5 as the count of passed students.
So Declare sum as long or long long because int would not be able to store such a large number.
n=1 is also possible. in which case your code would try to divide sum by “0” which is an invalid operation. So correct this too.
Also you need to consider cases of invalid inputs. one such example would be when n=5 and one of the student reports 6 as number of passed students.