问题遇到的现象和发生背景
错了
运行结果及报错内容
我的解答思路和尝试过的方法
用了函数和结构体来解决,但是不知道哪儿出错了
#include<stdio.h>
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<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;
}