c语言出错了help!help

问题遇到的现象和发生背景

错了

运行结果及报错内容

img

我的解答思路和尝试过的方法

用了函数和结构体来解决,但是不知道哪儿出错了

#include
typedef struct sd//定义结构体
{
int ch;
int math;
int eng;
int add;
}sd;
int judge(int a, int b)//判断单科分差
{
    int gg = 0;
    if ((a - b <= 5 )&&( a - b >= -5))
    {

    }
    else gg = 1;
    return gg;
}
int judgeadd(int a, int b)//判断总成绩分差是否符合条件
{
    int gg = 0;
    if ((a - b <= 10) &&( a - b >= -10))
    {

    }
    else gg = 1;
    return gg;
}
int   getresult(struct sd ss, struct sd bb)//判断两人是否符合标准
{
    int temp = 0;//ture
    if (judge(ss.math, bb.math) && judge(ss.ch, bb.ch) && judge(ss.eng, bb.eng) && judgeadd(ss.add, bb.add))
    {

    }
    else
        temp = 1;//false
    return temp;
}

int main()
{
    int count = 0;
    int n;
    scanf("%d", &n);
    sd stu[1000];
     for (int i = 0; i < n; i++)
     {
         scanf("%d %d %d", &stu[i].ch, &stu[i].math ,&stu[i].eng);//输入数据
         stu[i].add = (stu[i].ch + stu[i].math + stu[i].eng);
     }
     for (int i=0;i-1;i++)//遍历
     {


         for (int s=i+1;s//s不等于i
         {
             if (getresult(stu[i], stu[s]))
             {
                 count++;
             }
         }
     }
     printf("%d",count);//输出对数
    return 0;
}
我想要达到的结果

img

修改如下,供参考:

#include <stdio.h>
#include <stdlib.h>
typedef struct sd//定义结构体
{
    int ch;
    int math;
    int eng;
    int add;
}sd;
int judge(int a, int b)//判断单科分差
{
    return abs(a - b) <= 5;
    //int gg = 0;
    //if ((a - b <= 5) && (a - b >= -5))
    //{

    //}
    //else gg = 1;
    //return gg;
}
int judgeadd(int a, int b)//判断总成绩分差是否符合条件
{
    return abs(a - b) <= 10;
    //int gg = 0;
    //if ((a - b <= 10) && (a - b >= -10))
    //{

    //}
    //else gg = 1;
    //return gg;
}
int   getresult(struct sd ss, struct sd bb)//判断两人是否符合标准
{
    //int temp = 0;//ture
    if (judge(ss.math, bb.math) && judge(ss.ch, bb.ch) && judge(ss.eng, bb.eng) && judgeadd(ss.add, bb.add))
        return 1;
    else
        return 0;
    //{

    //}
    //else
    //    temp = 1;//false
    //return temp;
}

int main()
{
    int count = 0;
    int n;
    scanf("%d", &n);
    sd stu[1000];
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d", &stu[i].ch, &stu[i].math, &stu[i].eng);//输入数据
        stu[i].add = (stu[i].ch + stu[i].math + stu[i].eng);
    }
    for (int i = 0; i < n - 1; i++)//遍历
    {


        for (int s = i + 1; s < n; s++)//s不等于i
        {
            if (getresult(stu[i], stu[s]))
            {
                count++;
            }
        }
    }
    printf("%d", count);//输出对数
    return 0;
}

错误的原因是以为1为假,0为真了😂