输入N,再输入N个数,N<10000,这N个数大小1-100,输入M,请打印出M大值
各位大侠!小弟刚学C++,在线等!谢谢!
#include <stdio.h> int main( void ) { unsigned short buf[101] = {}; size_t n; scanf( "%zu", &n ); for( size_t i=0; i!=n; ++i ) { unsigned val; scanf( "%u", &val ); ++buf[val]; } size_t m; scanf( "%zu", &m ); for( size_t i=0; i!=n; ++i ) { if( m <= buf[i] ) { printf( "%zu\n", i ); break; } else m -= buf[i]; } }