Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
晕死,变量定义重复WA一次。。。附不用数组的解法,0ms#include <iostream> #include <cstring> #include <string> #include <stdio.h> #include <stdlib.h> #include <cmath> #include <queue> #include <algorithm> using namespace std; string f_ = " took clay from "; int main() { int n; while(1){ cin >> n; if(n<0)break; if(n==2){ int a,b,c,d,e,f; string s,t; cin >> a>>b>>c>>s>>d>>e>>f>>t; if(a*b*c>d*e*f) cout << s << f_ << t << "." << endl; else cout << t << f_ << s << "." << endl; continue; } int d,z,x, st=0; string ds,zs,xs; bool dd = 0; for(int i = 0; i < n; i++){ int a,b,c;string s; cin >> a >> b >> c >> s; if(dd) continue; int p = a*b*c; if(st==0){ d=p;ds=s;st=1; } else if(st==1){ if(p>d){ z=d;zs=ds;d=p;ds=s;st=2; } else if(p<d){ z=p;zs=s;st=2; } } else if(st==2){ if(p>d){ x=z;xs=zs;z=d;zs=ds;d=p;ds=s;st=3; } else if(p<d && p>z){ x=z;xs=zs;z=p;zs=s;st=3; } else if(p<z){ x=p;xs=s;st=3; } } else{ cout << ds << f_ << xs << "." << endl; dd=1; } } if(!dd){ cout << ds << f_ << xs << "." << endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator