⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toj_2859.cpp

📁 Tianjin University Online Judge 的80多道题目 .
💻 CPP
字号:
/*2859.   S Number Time Limit: 1.0 Seconds   Memory Limit: 65536KTotal Runs: 448   Accepted Runs: 268You are given a set of numbers. The number which is only less than the largest number is called as S-Number. For the number set which contains 8 numbers: 3, 6, 0, -5, 7, 7, 6, 2. The largest number is 7. So the S-Number is 6 because it is only less than 7.InputThe first line of each case contains a positive integer n that indicates the size of the set. Then n numbers followed, denotes the numbers in the set. The input is terminated by a single line n = 0. All the numbers in the input will be less than 100.OutputOne line contains the S-Number for each case.Sample Input83 6 0 -5 7 7 6 20Sample Output6Source: TJU Team Selection Contest 1*/#include<cstdio>#include<climits>int maxNum( int const  num[]  , int const len ){  int  i, max;  max = INT_MIN ;  for ( i = 0; i < len; i++ )    {      if ( num[ i ] > max )	max = num[ i ];    }  return max;}int main(){  int i , j  ,k , n , max;  int  num[ 200 ];  while ( scanf( "%d" , &n ) && n != 0 )    {      for ( i = 0; i < n; i++ )	{	  scanf( "%d"  , &num[ i ] );	}      max = maxNum( num , n );      for ( i = 0;  i < n; i++ )	{	  if ( num[ i ] == max )	    num[ i ] = INT_MIN;	}      max = maxNum( num , n );      printf( "%d\n" , max );    }}	              

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -