北大ACM poj1547 Clay Bully
来源:互联网 发布:mac怎么升级到10.13 编辑:程序博客网 时间:2024/05/30 19:33
Clay Bully
Description
Ms. Terry is a pre-school art teacher who likes to have her students work with clay. One of her assignments is to form a lump of clay into a block and then measure the dimensions of the block. However, in every class, there is always one child who insists on taking some clay from some other child. Since Ms. Terry always gives every child in a class the same amount of clay to begin with, you can write a program that helps Ms. Terry find the bully and victim after she measures each child's finished block.
Input
There are one or more classes of students, followed by a final line containing only the value -1. Each class starts with a line containing an integer, n, which is the number of students in the class, followed by n lines of student information. Each line of student information consists of three positive integers, representing the dimensions of the clay block, followed by the student's first name. There can never be more than 9 students nor less than 2 students in any class. Each student's name is at most 8 characters. Ms. Terry always gives each student at most 250 cubic units of clay. There is exactly one bully and one victim in each class.
Output
For each class print a single line exactly as shown in the sample output.
Sample Input
310 10 2 Jill5 3 10 Will5 5 10 Bill42 4 10 Cam4 3 7 Sam8 11 1 Graham6 2 7 Pam-1
Sample Output
Bill took clay from Will.Graham took clay from Cam.
//1547 //计算每个人拥有泥巴的大小,也就是体积,输入长宽高,体积最小和最大的就是要求的。#include<stdio.h>#include<stdlib.h>typedef struct Ren{int V;char na[9];}Ren;Ren ren[9];int cmp(const void *a,const void *b){return (*(Ren *)a).V - (*(Ren *)b).V; }main(){int n,a,b,c,i; while(scanf("%d",&n),~n)//n为-1结束 {for(i=0;i<n;i++){scanf("%d%d%d%s",&a,&b,&c,ren[i].na);//输入数据 ren[i].V=a*b*c;//计算体积,存入结构体 }qsort(ren,n,sizeof(ren[0]),cmp);//按体积排序 printf("%s took clay from %s.\n",ren[n-1].na,ren[0].na);}}
- 北大ACM poj1547 Clay Bully
- pku_1547 Clay Bully
- ZOJ 1755 Clay Bully
- zoj 1755 Clay Bully
- ZOJ 1755 Clay Bully
- zoj 1755 Clay Bully
- POJ 1547 Clay Bully
- POJ 1547:Clay Bully
- Clay Bully-1547
- POJ 1547 Clay Bully G++
- zoj 1755 Clay Bully(水~)
- ZOJ Problem Set - 1755 Clay Bully
- POJ 1547 Clay Bully 结构体数组使用题意理解
- ZOJ 1755 && POJ 1547 Clay Bully(简单排序+map容器)
- 北大ACM
- 北大ACM-题型分类
- 北大ACM题型分类
- 北大ACM做题小软件
- Advice From An Old Programmer
- SAP HANA DBA日常工作手册
- SAP HANA 行存储(SAP HANA Row Store)
- VMware中安装的ubuntu 10.04改变分辨率
- SAP HANA 发现并解决故障 (SAP HANA Troubleshooting)
- 北大ACM poj1547 Clay Bully
- js小知识点
- Delta Merge for SAP HANA
- 2012.8.3
- erlang中文手册——ets
- 软文营销的概念
- SAP HANA 用户管理(SAP HANA User Management)
- C#反编译中资源文件的恢复
- 收集值得一读的书籍