Skip to content

Instantly share code, notes, and snippets.

@modos
Created July 9, 2022 07:51
Show Gist options
  • Save modos/777f4d47e4431769527f50e1257b5592 to your computer and use it in GitHub Desktop.
Save modos/777f4d47e4431769527f50e1257b5592 to your computer and use it in GitHub Desktop.
کلید چراغ
/******************************************************************************
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;
}
@mrsedghi
Copy link

به زبان پایتون

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

i+=1

print(count)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment