PAT乙级1041 考试座位号 (15分)

这道题查错半天才找到错在哪:
long long类型数据在scanf、printf中对应的格式符是“ lld ”。

#pragma warning(disable:4996)
#include
using namespace std;

struct student {
	long long id;
	int seat;
	int test;
}Student[1010];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		getchar();
		scanf("%lld%d%d", &Student[i].id, &Student[i].test, &Student[i].seat);
	}
	int m;
	getchar();
	scanf("%d", &m);
	getchar();
	for (int i = 0; i < m; i++)
	{
		int temp;
		scanf("%d", &temp);
		for (int j = 0; j < n; j++)
			if (Student[j].test == temp)
			{
				printf("%lld %d", Student[j].id, Student[j].seat);
				break;
			}
		if (i != m - 1)
			printf("\n");
	}
}

你可能感兴趣的:(PAT)