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

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

code_blocks
مسئله مربوطه: دنیز و صف مدرسه (#25) arrow_outward
verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: C++
schedule
ارسال‌کننده و زمان:
shana (۲ سال پیش)
descriptionsolution.cpp ۷۱ خط • ۱٫۳ کیلوبایت
1#include <iostream>
2using namespace std;
3int main()
4{
5 int n , x , y , andaze1 , andaze2 , andaze3;
6 cin >> n >> y;
7 andaze1 = 0;
8 andaze2 = 0;
9 andaze3 = 0;
10
11 for ( int i = 0 ; i < n ; i ++ )
12 {
13 cin >> x;
14 if ( x < y )
15 {
16 if ( andaze1 == 0 )
17 {
18 cout << x <<" ";
19 andaze1 ++;
20 }
21
22 if ( andaze1 > 0 && i != 0 )
23 {
24 cout << x <<" ";
25 }
26
27 if ( i == n - 1 )
28 {
29 cout << y;
30 }
31 }
32
33 if ( x == y )
34 {
35 if ( andaze2 == 0 )
36 {
37 cout << x <<" " << y <<" ";
38 andaze2 ++;
39 }
40
41 else
42 {
43 cout << x <<" ";
44 }
45 }
46
47 if ( x > y )
48 {
49 if ( andaze2 == 0 )
50 {
51 if ( andaze3 == 0 )
52 {
53 cout << y <<" " << x <<" ";
54 andaze3 ++;
55 }
56
57 else
58 {
59 cout << x <<" ";
60 }
61 }
62
63 else
64 {
65 cout << x <<" ";
66 }
67 }
68 }
69
70 return 0;
71}
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8