输入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]; } }
[此贴子已经被作者于2019-3-5 10:58编辑过]