萌新求助!
查看原帖
萌新求助!
350959
Shh_hhS楼主2020/6/6 18:41
#include<stdio.h>
#include<math.h>
#include<string.h>

struct stu
{
	char name[8];
	int yu;
	int shu;
	int ying;
	int zong;
};

int main()
{
	struct stu s[1005];
	
	int n,i,j=i+1;
	
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%s%d%d%d",s[i].name,&s[i].yu,&s[i].shu,&s[i].ying);
		s[i].zong=s[i].yu+s[i].shu+s[i].ying;
	}
	i=0;
	
	int c1,c2,c3,c0;//差值 
	while(s[i].zong!=0)
	{
		while(s[j].zong!=0)
		{
			c1=abs(s[i].yu-s[j].yu);
			c2=abs(s[i].shu-s[j].shu);
			c3=abs(s[i].ying-s[j].ying);
			c0=abs(s[i].zong-s[j].zong);
			if(c1<=5&&c2<=5&&c3<=5&&c0<=10)
			{
				if(strcmp(s[i].name,s[j].name)>0)	printf("%s %s\n",s[j].name,s[i].name);
				else	printf("%s %s\n",s[i].name,s[j].name);
			}
		 
			j++;
		}
		i++;j=i+1;
	}
	
	return 0;
}

5个都是wrong。。

2020/6/6 18:41
加载中...