Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
704 B
1
Indexable
Never
#include <iostream>
using namespace std;
int main()
{
     int mas[10];
	 int a = 0;
	 int b = 0;
	 int max = 0;
	 int y = 0;
	 for (int i = 0; i < 10; i++)
	 {
		 cin >> mas[i];
	 }
	 for (int i = 0; i < 10; i++)
	 {
		 a = 0;
		 b = 0;
		 if (mas[i] == 1)
		 {
			 y = -1;
			 for (int u = i; u < 10; u++)
			 {
				 if (mas[u] == 2)
				 {
					 a = y;
				 }
				 y++;
			 }
			 y = -1;
			 for (int u = i; u > -1; u--)
			 {
				 if (mas[u] == 2)
				 {
					 b = y;
				 }
				 y++;
			 }
			 if (a == 0)
			 {
				 a = b;
			 }
			 if (a > b)
			 {
				 a = b;
			 }
			 if (a > max)
			 {
				 max = a;
			 }
		 }
	 }
	 cout << max;
	 return 0;
Leave a Comment