Back to the Training Home
Back to the Training Home
Lesson: 41
Problem: 2859
Title: S Number
Difficulty Level: 1.0
Date: MAR 03, 2009
Site: http://acm.tju.edu.cn/toj/showp2859.html
Can you find second highest number among an integer set ?
#include<stdio.h>
int A[101];
void Cal(int n) {
int max = -999999999, smax = -999999999, i;
for(i = 0; i<n; i++) {
scanf("%d",&A[i]);
if(max < A[i]) max = A[i];
}
for(i = 0; i<n; i++) {
if(A[i] == max) continue;
if(A[i] > smax) smax = A[i];
}
printf("%d\n",smax);
}
int main() {
int n;
while(scanf("%d",&n) && n) {
Cal(n);
}
return 0;
}
|