标签:des style blog io color os sp for strong
Description
Input
Output
Sample Input
Sample Output
#include<stdio.h> #include<algorithm> using namespace std; struct p{ int x; }digit[1000000]; //如果直接定义成digit[1000000]会溢出。但是用结构体则不会溢出 //为什么? bool cmp(p a,p b) { return a.x>b.x; } int main() { int M,N; while(scanf("%d%d",&N,&M)!=EOF){ int i; for(i=0;i<N;i++) scanf("%d",&digit[i].x); sort(digit,digit+N,cmp); for(i=0;i<M;i++){ if(i==0) printf("%d",digit[i].x); else printf(" %d",digit[i].x); } printf("\n"); } return 0; }
心得:
为啥这么坑???为什么定义成结构体会AC?而直接用数组则不行?
标签:des style blog io color os sp for strong
原文地址:http://www.cnblogs.com/yanglingwell/p/4080768.html