arrow_forward همه ارسال‌ها

جزئیات ارسال کد#502

verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: C++
schedule
ارسال‌کننده و زمان:
shana (۲ سال پیش)
descriptionsolution.cpp ۳۳ خط • ۵۳۰ بایت
1#include <iostream>
2using namespace std;
3int main()
4{
5 int n , x , big , Big , no1 , no2;
6 cin >> n;
7 big = 0;
8 Big = 0;
9 no1 = 0;
10 no2 = 0;
11
12 for ( int i = 0 ; i < n ; i ++ )
13 {
14 cin >> x;
15 if ( x > Big )
16 {
17 big = Big;
18 no1 = no2;
19 Big = x;
20 no2 = i;
21 }
22
23 else if ( x > big )
24 {
25 big = x;
26 no1 = i;
27 }
28 }
29
30 cout << abs(no2 - no1);
31
32 return 0;
33}
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8