国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

PAT 1012

2019-11-08 02:00:43
字體:
來源:轉載
供稿:網友
#include<cstdio>#include<algorithm>#include<stdlib.h>#include<cstring>using namespace std;struct student{	int id;	int score[4];}st[1000010];char map[4]={'A','C','M','E'};int now;int k[1000010][4]={0};//局部變量是放在棧里面的,棧的空間通常都不會太大,定義這么大一個局部數組,放在main函數內會導致棧溢出。//一般來說,大數組最好不要定義為局部變量,要么改成全局變量,要么使用動態內存分配。 bool cmp(student x,student y){		return x.score[now]>y.score[now];}int main(){		int n,m;		scanf("%d%d",&n,&m);	for(int i=0;i<n;i++)	{		scanf("%d%d%d%d",&st[i].id,&st[i].score[1],&st[i].score[2],&st[i].score[3]);		st[i].score[0]=st[i].score[1]+st[i].score[2]+st[i].score[3];//round	}		for(now=0;now<4;now++)	{		 sort(st,st+n,cmp);		 k[st[0].id][now]=1;		 for(int j=1;j<n;j++)		 {			 if(st[j].score[now]!=st[j-1].score[now])				 k[st[j].id][now]=j+1;			 else 				 k[st[j].id][now]=k[st[j-1].id][now];						 }	}	int query;	for(int i=0;i<m;i++)	{		scanf("%d",&query);		if(k[query][0]==0)			PRintf("N/A/n");		else		{			int x=0;			for(int y=1;y<4;y++)			{				if(k[query][y]<k[query][x])				{					x=y;								}			}			printf("%d %c/n",k[query][x],map[x]);		}	}	system("pause");	return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 游戏| 阿鲁科尔沁旗| 阳山县| 唐海县| 临海市| 冀州市| 陇西县| 抚远县| 陆丰市| 巧家县| 五台县| 通榆县| 阜南县| 平武县| 炎陵县| 确山县| 荆州市| 清河县| 陇南市| 惠东县| 瑞昌市| 崇仁县| 深水埗区| 台湾省| 滦南县| 金山区| 台南市| 潼关县| 台南县| 图片| 兴化市| 乳源| 措美县| 南丹县| 石首市| 黑河市| 克山县| 新余市| 石棉县| 望谟县| 水城县|