自己写的比较麻烦 将就看一下
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>using namespace std;int n,y,z;char x[25],p[25];struct data{ char name[25]; int qian,num,_num;};data a[15];bool cmp(data a,data b){ return a._num<b._num;}int check(char *x){ for(int i=1;i<=n;i++) if(strcmp(a[i].name,x)==0) return a[i].num;}int main(){ //freopen("in.txt","r",stdin); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%s",a[i].name); a[i].num=i;a[i].qian=0; } for(int i=1;i<=n;i++) { scanf("%s%d%d",x,&y,&z); a[i]._num=i; int QQ=check(x); int r=1; if(z!=0) r=y-y/z*z; else r=0; a[qq].qian=a[qq].qian-y+r; for(int j=1;j<=z;j++) { scanf("%s",p); int qq=check(p); if(z!=0) a[qq].qian+=y/z; else a[qq].qian+=0; } } sort(a+1,a+n+1,cmp); for(int i=1;i<=n;i++) { PRintf("%s %d/n",a[i].name,a[i].qian); } return 0;}新闻热点
疑难解答