#include <bits/stdc++.h> using namespace std; int jd; int main(){ int a; int tab[a]; cin >> a; int b= a/10; for(int i=0; i<a; i+=b) { cin >> tab[i]; if(tab[i] == tab[i+1]) { tab[i] = 'N'; tab[i-1] = 'N'; jd++; } } cout << jd; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <bits/stdc++.h> using namespace std; int jd; int main(){ int a; int tab[a]; cin >> a; int b= a/10; for(int i=0; i<a; i+=b) { cin >> tab[i]; if(tab[i] == tab[i+1]) { tab[i] = 'N'; tab[i-1] = 'N'; jd++; } } cout << jd; } |