SDUT 选夫婿1 http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1569&cid=1211

 
#include<stdio.h>
#include<string.h>
void main()
{
	char str[20][100];
	int n, i, j, k, high[100], weight[100];
	int hl, hr, wl, wr, t1, t2, count=0;
	char t3[100];
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%s", str[i]);
		scanf("%d %d", &high[i], &weight[i]);
	}
	scanf("%d %d %d %d", &hl, &hr, &wl, &wr);
	for(i=0; i<n-1; i++)
		for(j=i+1; j<n; j++)
		{
			if(high[i]>high[j])
			{
				t1 = high[i];
				high[i] = high[j];
				high[j] = t1;

				t2 = weight[i];
				weight[i] = weight[j];
				weight[j] = t2;

				strcpy(t3, str[i]);
				strcpy(str[i], str[j]);
				strcpy(str[j], t3);
			}
			if(high[i]==high[j] && weight[i] > weight[j])
			{
			   

				t2 = weight[i];
				weight[i] = weight[j];
				weight[j] = t2;

				strcpy(t3, str[i]);
				strcpy(str[i], str[j]);
				strcpy(str[j], t3);
			}


		}

		for(i=0; i<n; i++)
		{
			if(high[i] >= hl && high[i] <= hr && weight[i] >= wl && weight[i] <= wr)
			{
				
				printf("%s %d %d\n", str[i], high[i], weight[i]);
			count++;
					
			}
		}
		if(count==0)
			printf("No\n");
		

}

posted @ 2014-01-17 19:25  6bing  阅读(174)  评论(0编辑  收藏  举报