Created
July 9, 2022 07:51
-
-
Save modos/777f4d47e4431769527f50e1257b5592 to your computer and use it in GitHub Desktop.
کلید چراغ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
Online C++ Compiler. | |
Code, Compile, Run and Debug C++ program online. | |
Write your code in this editor and press "Run" button to compile and execute it. | |
*******************************************************************************/ | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int n; | |
cin >> n; | |
int arr[n]; | |
for (int i = 0; i < n; i++) { | |
cin >> arr[i]; | |
} | |
int count = 0; | |
for (int i = 1; i < n; i++) { | |
if (arr[i] != arr[i - 1]){count++;} | |
} | |
cout << count; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
به زبان پایتون
n=int(input())
arr=[]
for i in range(n):
arr.append(input())
count=0
i=1
while i<n:
if arr[i] != arr[i-1]:
count+=1
print(count)