#include <stdio.h>
struct students
{
char number[10];
int dpoint;
int cpoint;
};
int main()
{
int N, L, H;
scanf_s("%d%d%d", &N, &L, &H);
int i,j;
int num = 0,num2=0,num3=0,num4=0,num5=0;
struct students stu[100];
int temp;
for (i = 0; i < N; i++)
{
scanf_s("%s%d%d", stu[i].number, stu[i].dpoint, stu[i].cpoint);
}
int sum = stu[i].dpoint + stu[i].cpoint;
for (i = 0; i < N; i++)
{
if ((stu[i].dpoint >= L) && (stu[i].cpoint >= L))
num++;
if ((stu[i].dpoint >= H) && (stu[i].cpoint >= H))
num2++;
if ((stu[i].dpoint >=H) && (stu[i].cpoint <H))
num3++;
if ((stu[i].cpoint <H) && (stu[i].dpoint < H)&&(stu[i].dpoint>stu[i].cpoint))
num4++;
if ((stu[i].dpoint >= L) && (stu[i].dpoint < H) && (stu[i].cpoint >= L) && (stu[i].cpoint < H))
num5++;
}
printf("%d", num);
for (i = 0; i < num2; i++)
{
int max = stu[i].dpoint + stu[i].cpoint;
for (j = i; j < num2; j++)
{
if ((stu[j].dpoint + stu[j].cpoint) > max)
max = stu[j].cpoint + stu[j].dpoint;
}
if (max != (stu[i].cpoint + stu[i].dpoint))
{
int sum1 = stu[i].dpoint + stu[i].cpoint;
temp = max;
max = sum1;
sum1 = temp;
}
}
for (i = 0; i < num2; i++)
{
printf("%s %d %d", stu[i].number, stu[i].dpoint, stu[i].cpoint);
printf("\n");
}
for (i = 0; i < num3; i++)
{
int max = stu[i].dpoint + stu[i].cpoint;
for (j = i; j < num3; j++)
{
if ((stu[j].dpoint + stu[j].cpoint) > max)
max = stu[j].cpoint + stu[j].dpoint;
}
if (max != (stu[i].cpoint + stu[i].dpoint))
{
int sum2 = stu[i].dpoint + stu[i].cpoint;
temp = max;
max = sum2;
sum2 = temp;
}
}
for (i = 0; i < num3; i++)
{
printf("%s %d %d", stu[i].number, stu[i].dpoint, stu[i].cpoint);
printf("\n");
}
for (i = 0; i < num4; i++)
{
int max = stu[i].dpoint + stu[i].cpoint;
for (j = i; j < num4; j++)
{
if ((stu[j].dpoint + stu[j].cpoint) > max)
max = stu[j].cpoint + stu[j].dpoint;
}
if (max != (stu[i].cpoint + stu[i].dpoint))
{
int sum3 = stu[i].dpoint + stu[i].cpoint;
temp = max;
max = sum3;
sum3 = temp;
}
}
for (i = 0; i < num5; i++)
{
printf("%s %d %d", stu[i].number, stu[i].dpoint, stu[i].cpoint);
printf("\n");
}
for (i = 0; i < num5; i++)
{
int max = stu[i].dpoint + stu[i].cpoint;
for (j = i; j < num4; j++)
{
if ((stu[j].dpoint + stu[j].cpoint) > max)
max = stu[j].cpoint + stu[j].dpoint;
}
if (max != (stu[i].cpoint + stu[i].dpoint))
{
int sum4 = stu[i].dpoint + stu[i].cpoint;
temp = max;
max = sum4;
sum4 = temp;
}
}
for (i = 0; i < num5; i++)
{
printf("%s %d %d", stu[i].number, stu[i].dpoint, stu[i].cpoint);
printf("\n");
}
}
我在输入区粘贴引例的数据时,数据无法全部正常输入,问题在哪里呢?同时希望大家帮我看一下代码其他地方有无问题,谢谢大家!