poj 1547(水題)
阿新 • • 發佈:2021-07-29
#include<iostream> #include<cstdio> using namespace std; int main(){ int n,maxv,maxi,minv,mini,a,b,c,v; char data[10][10]; while(scanf("%d",&n)==1&&n!=-1){ maxv = -1; minv = 1000; for(int i=0;i<n;i++){ scanf("%d%d%d",&a,&b,&c); scanf("%s",data[i]); v = a*b*c; if(maxv<v){ maxv = v; maxi = i; } if(minv>v){ minv = v; mini = i; } } printf("%s took clay from %s.\n",data[maxi],data[mini]); }return 0; }#include<iostream> #include<cstdio> using namespace std; int main(){ int n,maxv,maxi,minv,mini,a,b,c,v; char data[10][10]; while(scanf("%d",&n)==1&&n!=-1){ maxv = -1; minv = 1000; for(int i=0;i<n;i++){ scanf("%d%d%d",&a,&b,&c); scanf("%s",data[i]); v = a*b*c; if(maxv<v){ maxv = v; maxi = i; } if(minv>v){ minv = v; mini = i; } } printf("%s took clay from %s.\n",data[maxi],data[mini]); } return 0; }