poj 1547(水题)

#include<iostream>
using namespace std;
int main(){
    int n;
    int x,y,z,data[10];
    char name[10][10];
    int maxv,minv,maxi,mini;
    while(scanf("%d",&n)==1&&n!=-1){
        maxv = -1;
        minv = 9999;
        for(int i=0;i<n;i++){
            scanf("%d%d%d%s",&x,&y,&z,name[i]);
            data[i] = x*y*z;
            if(data[i]>maxv){
                maxv = data[i];
                maxi = i;
            }
            if(data[i]<minv){
                minv = data[i];
                mini = i;
            }
        }
        printf("%s took clay from %s.\n",name[maxi],name[mini]);
    }
    return 0;
} 

 

上一篇:2021.12.11模拟总结


下一篇:Leetcode152:乘积最大子数组(动态规划,维护两个状态表)